-
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
non-nullable @external field that are not part of @key fieldset blows up federation #2357
Comments
Update `gqlgen` integration with latest schema changes. Related: * resolves: apollographql#184 * `@requires` is not supported due to 99designs/gqlgen#2357
Update `gqlgen` integration with latest schema changes. Related: * resolves: #184 * `@requires` is not supported due to 99designs/gqlgen#2357
Can you please see if #2371 addressed your issue? If not, can you submit a PR? |
👋 referenced PR fixed directive definitions which is great but does not solve the underlying issue. Issue here is that codegen assumes that ALL
While this use case may not be clear from the example app schema as gateway would never attempt to resolve just the
If we now get a query asking for just |
IMHO the simplest solution would be to check whether the representation map contains entries for those non-nullable fields and only then attempt to populate corresponding fields. As for the PR -> sorry but won't be able to work on this anytime soon. |
Ok, I burned through my OSS hours for this week, but would fast-track reviewing any PR for this. Thanks for providing more information! |
Hi people, other than the issue discussed in this issue, there's another issue with |
@shawnhugginsjr @jclyons52 @lleadbet Hey, if one of you has a chance to work on fixing our outstanding issue with Apollo Federation support, I would love a PR! |
Facing similar issue where getting |
According to https://www.apollographql.com/docs/federation/v1/federation-spec/#scalar-_fieldset the selection can only be a fieldset Is this different in v2 of the federation spec? |
fixed in #2884 |
What happened?
If schema specifies non-nullable
@external
fields that are not part of the@key
field set, entity resolution will blow up trying to coercenil
to a target type even if they are not part of the query. Those fields will only be correctly coerced if end user select a field that references those external fields using@requires
field set. It appears that the current logic assumes that those fields will always be populated in entity representation.Example use case from https://github.com/apollographql/apollo-federation-subgraph-compatibility. Given a type definition
@requires
directive allows to reference external fields that are necessary for calculating its value. Those@external
fields will be provided in the entity representation ONLY if field referencing them is requested (i.e. router will only includetotalProductsCreated
andyearsOfEmployment
in the user entity representation ifaverageProductsCreatedPerYear
is in query selection set). Attempting to run a query without@requires
field blows up the execution, e.g.What did you expect?
Query is executed successfully even if those fields are referenced by the selection set (i.e. they are not populated).
Minimal graphql.schema and models to reproduce
Start example
reviews
server from https://github.com/99designs/gqlgen/tree/v0.17.16/_examples/federationExecute following query
Variables
Execution blows up at https://github.com/99designs/gqlgen/blob/v0.17.16/_examples/federation/reviews/graph/generated/federation.go#L124 with
interface conversion: interface {} is nil, not map[string]interface {}
versions
go run github.com/99designs/gqlgen version
v0.17.16go version
go1.19 darwin/arm64The text was updated successfully, but these errors were encountered: