Search code examples
graphqlgraphql-jsprismaprisma-graphql

Prisma - Graphql queries on preloaded mysql database returning empty


Looking for how to debug this or a reason why it might be returning empty.

I'm using Prisma graphql with a mysql databse and I was able to preload the database with data and then set up the schema to match the database.

For example I have the schema:

# Also tried renaming this to PRIMITIVE_TYPE but no luck
type PrimitiveType {
  PRIMITIVE_TYPE_ID: Int! @unique
  PRIMITIVE_TYPE: String!
}

and in the database it was created with:

CREATE TABLE PRIMITIVE_TYPE
(
    PRIMITIVE_TYPE_ID SMALLINT NOT NULL,
    PRIMITIVE_TYPE VARCHAR(20) NOT NULL,
);
ALTER TABLE PRIMITIVE_TYPE ADD CONSTRAINT CONSTRAINT_24 PRIMARY KEY
(PRIMITIVE_TYPE_ID);

everything starts up fine and the playground recognizes the schema. But when I try

{
  primitiveTypes {
    PRIMITIVE_TYPE_ID
    PRIMITIVE_TYPE
  }
}

It just returns

{
  "data": {
    "primitiveTypes": []
  }
}

I connected to the database manually and the table had data in it, I'm not really sure what else to try or how to debug it.


Solution

  • This was basically due to the fact that prisma has yet to implement mysql introspection. They are currently working it now.