Repository navigation
feat(graphql): allow fields to reference the root query type - #4196
Merged
Merged
Conversation
Merged
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
PR Type
What is the current behavior?
In code first, there is no way to reference the generated root
Querytype from an object type field, so the "mutation payload query" pattern (a payload exposingquery: Query!, common with Relay, so clients can refetch anything after a mutation in one round trip) needs atransformSchemaworkaround.@Field(() => 'Query')fails with "Cannot determine a GraphQL output type".Issue Number: #2738
What is the new behavior?
Object type fields can return the generated root
Querytype by name:Output types could already be referenced by name, but the root types were never registered.
QueryTypeFactorynow registers the generatedQuerytype, and since object type fields are resolved lazily (after the root types are built), the reference works without ordering changes. OnlyQueryis registered: nested mutation fields would not execute serially.TypeDefinitionsStorage.clear()now also resets the name-based lookup between schema builds.Schema first already supports this (
query: Query!in SDL).Does this PR introduce a breaking change?
Closes #2738