fix(resolvers/federation): only transform federated parent types when they contain @external directive #4542
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR seeks to fix the issue raised in #4493
This updates the
transformParentType
function to only transform parent types if one of their fields contains an @external directive, or if the field is named__resolveReference
. This essentially translates to whether the type extends a type defined in a remote schema, or whether the type is a base type.The objective is to target only the resolvers that the gateway will call from the
_entities
query in a federated schema. The gateway only guarantees that fields from the@key
or@requires
directives will be supplied in the parent type, so we limit the parent type to only contain these fields. If the parent type is a base type, however, then its field resolvers (other than__resolveReference
) will be called from elsewhere, so we therefore go with the default behavior which is to assume all fields will be available.