test(graphql): cover doctrine collection in dto cursor pagination#8264
Closed
soyuka wants to merge 1 commit into
Closed
test(graphql): cover doctrine collection in dto cursor pagination#8264soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
Adds a functional GraphQL test pinning the resolution of a Doctrine \Doctrine\Common\Collections\Collection field on a DTO inside the cursor-based pagination wrapper (edges/node). This case differs from api-platform#8076 (plain array property) by exercising the Doctrine Collection path through the AbstractItemNormalizer's to-many relation handling before the GraphQL field resolver wraps the already-normalized array in an ArrayPaginator. Fixes api-platform#7038
Member
Author
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
Adds a functional GraphQL regression test pinning the resolution of a
\Doctrine\Common\Collections\Collectionfield on a DTO returned throughthe cursor-based pagination wrapper (edges/node).
The bug reported in #7038 (
GraphQL operations return null for DTO collections while REST operations work correctly) is already fixed by upstreamcommit
b714a4451("fix(graphql): nested resources without graphqloperationspropagate fields", PR #8076).
Reverting that commit reproduces the exact error from the issue:
Cannot return null for non-nullable field "Category.name". The reporter'sscenario used
Collection<Category>while #8076's test pinnedarray<Category>.Both shapes hit the same path
(
AbstractItemNormalizer::getAttributeValue→normalizeCollectionOfRelationsreturns a plain array before the GraphQL field resolver wraps it in
ArrayPaginator), but only the array form was pinned by a test until now.Reproduction
Pre-#8076:
Cannot return null for non-nullable field "Category.name"on a GraphQLquery of a DTO that exposes a
Collection<NestedResource>. Post-#8076: resolvescorrectly. This test pins the Doctrine-Collection case to keep it from
regressing.
Test plan
tests/Functional/GraphQl/Issue7038Test.phpcovering theDoctrine
Collection<>field on a DTO under cursor pagination.Fixes #7038