How to "pass through" or "schema stitch" underlying Prisma schema to parent schema?


I’m building on top of a postgres database. Prisma is generating the mutations/queries that, in most cases, I want to directly use in my end user graphql schema, for example updateUser.

In my schema.graphql file (which defines my apollo server schema), I’ve tried importing the generated prisma mutation:

# import Mutation.updateUser from './generated/prisma.graphql'

This works without error, and when I run my apollo server graphql playground, I get the full schema for updateUser auto completing, and I’m able to run the mutation.

However, the mutation run just returns null. I don’t see anything logged in the prisma docker container. I don’t see errors anywhere. I don’t see anything in the DB changed. I’m having the same issue if I try another mutation like createUser, except the error returned is

Cannot return null for non-nullable field Mutation.createUser

I assume I’m missing something, since I’m expecting this to work out of the box.

Is what I want to do possible? I think I get that I can completely copy all args down from my apollo server and call prisma.updateUser(), but that seems like duplication to me. I’d rather just selectively expose resolvers and mutations up from Prisma, since they already have the well defined API I want my clients to used.


Seems you forgot to add resolvers…

And yes, what you want to do is possible using prisma bindings. Assuming you have a prisma bindings instance on ctx.prisma.bindings:

// Mutation.js
module.exports = {
  createUser: (obj, args, ctx, info) => ctx.prisma.bindings.mutation.createUser(args, info)

Passing args does what you expect, passing info tells prisma what fields you want so the query can go multiple layers deep.


Ok, thank you, that is working, but when I’m trying to do skip/first pagination, I’m trying to get the total result count so I can create the pagination. When I query for aggregate { count } on something like

    usersConnection(parent, args, { prisma }, info) {
      return prisma.query.usersConnection(args, info);

Then the aggregate.count is returned, but it’s only for the count of the existing page set, not the total count. How do I get the total count?


Here is a pagination query that might be a usefull example:

query EmployeePagination ($first: Int! $skip: Int! $orderBy: EmployeeOrderByInput $where: EmployeeWhereInput) {
  meta: employeesConnection (where: $where) {
    aggregate {
  data: employees (first: $first skip: $skip orderBy: $orderBy where: $where) {
    # other fields...