Can someone point to me some examples or docs on h...
# orm-help
r
Can someone point to me some examples or docs on how to express nested relations in resolvers? For example, I have a Form type with a collection of FormEntry items. My resolver is simply calling ctx.db.query.forms(null, info), and I am able to query for "forms", but the nested "formEntries" always come back as null.
You will likely need to implement a resolver for the
FormEntry
type
r
hmm, I think you might want to use the
prisma-binding
library for this. We observed the same issue, that it wouldn’t return the nested objects. But using
prisma-binding
instead of the prisma client did return the nested objects.
r
I actually am using
prisma-binding
. it is passed into the Context when instantiating the server:
Copy code
const db = new Prisma({
  typeDefs: 'src/generated/prisma.graphql', // the auto-generated GraphQL schema of the Prisma API
  endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`)
  secret: process.env.PRISMA_SECRET // only needed if specified in `database/prisma.yml` (value set in `.env`)
  // debug: true // log all GraphQL queries & mutations sent to the Prisma API
})
Copy code
const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: req => ({ ...req, db })
})