Child objects return as null when query is executed via graphql-yoga endpoint, but work fine when queried via prisma endpoint

prisma

#1

Hello,
I am new to prisma and graphql-yoga. I have a very simple relationship example that works great when sent to the prisma endpoint, but does not work so well when it is sent to the graphql-yoga endpoint.

Types:
type ParentContainer {
    id: ID! @unique
    name: String!
    children: [ChildContainer!]!
}
type ChildContainer {
    id: ID! @unique
    name: String!
}

export const Query = {
  parentContainers(parent, args, ctx, info) {
    return ctx.prisma.parentContainers(args);
}

when I execute the following in playground http://localhost:4466/
{
parentContainers {
id
name
children {
id
name
}
}
}

{
  "data": {
    "parentContainers": [
      {
        "id": "cjp8v8s5p003h092673ela2oz",
        "name": "Kevin",
        "children": [
          {
            "id": "cjp8v8s5t003i0926c4avlf66",
            "name": "Cody"
          }
        ]
      }
    ]
  }
}

But when the query is executed against graphql-yoga the children come back null. I know I am most likely missing something very simple, but I can’t figure out what.

{
  "data": {
    "parentContainers": [
      {
        "id": "cjp8v8s5p003h092673ela2oz",
        "name": "Kevin",
        "children": null
      }
    ]
  }
}

any info will be greatly appreciated.


#2

Here is a follow on question:
How does the selectionSet get passed down from the resolvers to prisma implementation?
I can’t find anyway take the info Object and get it to prisma without using prisma-bindings.

What am I missing?


#3

From the Prisma docs:

Whenever a model is queried using the Prisma client, all scalar fields of that model are fetched. This is true no matter if a single object or a list of objects is queried.

You’ll have to define the resolver for children in ParentContainer.

Here is a SO question with an answer from a Prisma dev. https://stackoverflow.com/questions/52710372/include-relationship-when-querying-node-using-prisma-generated-wrapper


#4

@cjcaj Thxs! This pointed me the information I needed and helped clarify prisma-binding vs prisma-client, It would be MUCH easier if the info object could be utilized in prisma-client, but I have a path forward.

Thxs!
kshenes