fix(graphql): return identifier-only node on circular reference#8239
Merged
soyuka merged 1 commit intoJun 4, 2026
Merged
Conversation
553ea23 to
cb810f8
Compare
Skip Issue8080 test on MongoDB — entities are ORM-only (no Document equivalents). Avoids MappingException in MongoDB CI run. Fixes api-platform#8080
cb810f8 to
0c852af
Compare
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
When a Doctrine entity has mutual
ManyToOne/OneToManyreferences (e.g.Customer ↔ Address) and a GraphQL query traverses the cycle, the default Symfonycircular_reference_handlerreturns the visited object's IRI as a string. The GraphQLItemNormalizerandObjectNormalizerthen asserted the inner result was an array and threwExpected data to be an array., crashing the response with a 500.This PR makes both normalizers return an identifier-only node (
#itemResourceClass+#itemIdentifiers) when the innernormalize()yields a string, so the GraphQL field shape is preserved and the cycle is reported as already-visited instead of crashing.Fixes #8080.
Test plan
tests/Functional/GraphQl/Issue8080Test.php— minimal reproduction with twoApiResourceentities (Issue8080Customer,Issue8080Address) cross-referencing each other; query traverses the cycle and asserts noerrorskey in the response.vendor/bin/phpunit tests/Functional/GraphQl— 148 tests, all green.vendor/bin/phpunit src/GraphQl/Tests— 242 tests, all green.vendor/bin/phpunit tests/Functional— 1564 tests, all green.vendor/bin/phpstan analyse src/GraphQl/Serializer/ItemNormalizer.php src/GraphQl/Serializer/ObjectNormalizer.php— no errors.