-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
graphql: add FieldContext.Child field function and enable it in codegen #2062
Conversation
d6b2af0
to
0b60785
Compare
This is great! Thanks so much! |
Do we need to update docs for these changes? |
0b60785
to
395b4c1
Compare
I rebased it for you to fix the conflicts |
Thanks, @StevenACoffman. @frederikhors, I'll extend the godoc for it before landing it. |
Yes, please. Features without docs == no features at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you land it yourself.
Added godoc and merged. Thanks for the review @StevenACoffman and @frederikhors. |
Pasting here the discussion from gqlgen Discord:
In Ent, we have a nice workaround for the N+1 problem when working with gqlgen (see https://entgo.io/docs/tutorial-todo-gql-field-collection#ent-solution), and we do it by reading the query fields recursively and constructing one Ent query for the GraphQL query.
However, we have a problem when a field accepts arguments as parameters - we can't get them today with the current API. We use "fields collection" to get the "raw arguments", but that's not enough as we need the "processed version" that exists in the
FieldContext
in order to evaluate the Ent query.This PR adds a new field function to the
graphql.FieldContext
namedChild
that gets agraphql.CollectedField
object and returns the processedgraphql.FieldContext
for the collected field. This can also solve #1144.