Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make field selections available in context #65

Merged
merged 4 commits into from
Mar 28, 2018
Merged

Make field selections available in context #65

merged 4 commits into from
Mar 28, 2018

Conversation

vektah
Copy link
Collaborator

@vektah vektah commented Mar 27, 2018

This moves a bunch of the request state into two context objects:

  • RequestContext, for the stuff that doesn't change over the life of the request (variables, fragments, errors, etc)
  • ResolverContext, for the stuff that changes per resolver. currently this is only the field set.

This allows resolvers to reach into context to find the current fields and resolve the fragments. This should be enough info to reconstruct a graphql query for schema stitching. It also lets the db layer only fetch the fields that the user requested (fixes #27)

I've added a new example for working with the fields from context, but these APIs should be considered very unstable until the some of the schema stitching stuff lands.

Feedback appreciated!

@vektah vektah merged commit 71c4e26 into master Mar 28, 2018
@vektah vektah deleted the context branch March 28, 2018 08:57
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
Make field selections available in context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Access selected fields in resolver
1 participant