0
votes

I've seen several sources describe the (root, args, context, info) arguments to a graphql-yoga resolver, but I am still searching for the real documentation of a graphql-yoga resolver. There are a few blog posts that mention the resolver arguments:

  1. prisma blog - Feb 2017 - GraphQL Schemas, TypeDefs & Resolvers Explained
  2. prisma blog - Feb 2018 - Demystifying the info Argument in GraphQL Resolvers

I know that prisma has built graphql-yoga on graphql.js via graphql-tools, and it appears that graphql.js documents these parameters at graphql.org - Root fields & resolvers, but it's not clear if graphql.org is the main place where graphql.js is documented, and even if it was, it is not clear to me that as a user of graphql-yoga I should defer to the documentation of graphql.js.

In addition, prisma has built graphql-yoga on apollo-server; is the documentation for apollo-server most applicable here?

It doesn't appear that these arguments are part of the GraphQL spec.

Where is the real documentation for the arguments to a graphql-yoga resolver? If that is not available and documented, where in the graphql-yoga source is the function that expects the arguments to take this shape?

1
Why the downvote? I have made a good faith effort to use stack overflow correctly with this question - please explain why you think this question is not a good fit. There's even a stack overflow meta question which affirms that well-written questions about documentation are on topic: meta.stackoverflow.com/questions/288008/…Myer

1 Answers

3
votes

TL;DR

For use with graphql-yoga, you probably want to follow apollo-server's docs for resolvers in the graphql-tools section for Resolver function signature.

Details

To know which docs to use, one needs to understand the full tech stack: prisma built stuff on top of tools by apollo, which in turn is built on top of the reference implementation of GraphQL, graphql.js. Each layer of this stack has a separate docs site.

You can follow the trail from the graphql-yoga README, which says it is built on apollo-server, whose own README in turn says:

Apollo Server works with any GraphQL schema built with GraphQL.js, so you can build your schema with that directly or with a convenience library such as graphql-tools.

So graphql-yoga is an opinionated, batteries-included form of apollo-server, which takes schemas from graphql.js but is likely to have more seamless integration with schemas specified with apollo's own graphql-tools.