Import new prisma `@pgtable` directive in `prisma-binding`



I have a prisma 1.9 server deployed on top of an existing PostgreSQL. The schema looks like this

type User @pgTable(name: "users") {
  id: ID! @unique
  name: String!

When I try to create a graphql application server using prisma-binding, I got the error from graphql-import that

Error: Directive pgTable: Couldn't find type pgTable in any of the schemas.

The prisma constructor looks like

const db = new Prisma({
  typeDefs: 'src/prisma.graphql',
  endpoint: '...',
  secret: 'mysecret123',

Do you guys know how to import the pgTable directive in prisma-binding? Thanks.


I figured it out. I was using the datamodel.graphql (renamed to prisma.graphql in the example) as the typeDefs argument. Whereas I should really use graphql getschema to obtain the schema file from my prisma endpoint.


Hey @flexlee, which example are you referring to? The datamodel shouldn’t be called prisma.graphql, the convention is to call the datamodel datamodel.graphql and the resulting schema prisma.graphql.


I was referring to the code snippet in my original question. Initially I was importing datamodel.graphql in new Prisma(). Then I figured out I should really run graphql get-schema to generate a prisma.graphql file and use that file in new Prisma(). Thanks.


Great! :slight_smile: Glad you found that out, we should try to make this clearer in our documentation + examples.