fix(graphql): honor custom mutation output class in payload type#8300
Open
soyuka wants to merge 1 commit into
Open
fix(graphql): honor custom mutation output class in payload type#8300soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
A custom GraphQL mutation declaring its own output class reused the item_query type for its wrapped payload when normalization contexts matched, exposing the resource fields instead of the output DTO. Force a dedicated wrapped type when the mutation output class differs from the query output class. Fixes api-platform#2754
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.
Summary
A custom GraphQL mutation declaring its own
outputclass did not expose that class on its payload type. When the mutation and query normalization contexts matched,TypeBuilderreused theitem_querytype for the wrapped payload (to allow client cache sharing), so the payload exposed the resource fields instead of the output DTO — producing the reportedCannot query field "X" on type "...". The fix forces a dedicated wrapped type whenever the mutation's output class differs from the query operation's output class.Reproduction
A resource with a custom
Mutation(resolver: ..., output: SumResult::class)whose output DTO has different fields than the resource: before the fix, querying the DTO's fields on the mutation payload fails; the payload carries the resource's fields.Test plan
tests/Functional/GraphQl/Issue2754Test.php) covering the bug.TypeBuilder/introspection/schema-export tests still pass locally.Fixes #2754