Skip to content

test(graphql): cover doctrine collection in dto cursor pagination#8264

Closed
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/graphql-dto-collection-null-7038
Closed

test(graphql): cover doctrine collection in dto cursor pagination#8264
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/graphql-dto-collection-null-7038

Conversation

@soyuka

@soyuka soyuka commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

Adds a functional GraphQL regression test pinning the resolution of a
\Doctrine\Common\Collections\Collection field on a DTO returned through
the 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 upstream
commit b714a4451 ("fix(graphql): nested resources without graphqloperations
propagate fields", PR #8076).

Reverting that commit reproduces the exact error from the issue:
Cannot return null for non-nullable field "Category.name". The reporter's
scenario used Collection<Category> while #8076's test pinned array<Category>.
Both shapes hit the same path
(AbstractItemNormalizer::getAttributeValuenormalizeCollectionOfRelations
returns 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 GraphQL
query of a DTO that exposes a Collection<NestedResource>. Post-#8076: resolves
correctly. This test pins the Doctrine-Collection case to keep it from
regressing.

Test plan

  • Added tests/Functional/GraphQl/Issue7038Test.php covering the
    Doctrine Collection<> field on a DTO under cursor pagination.
  • All 153 GraphQl functional tests pass locally (8 new assertions).
  • phpstan + cs-fixer clean.

Fixes #7038

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
@soyuka

soyuka commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Closing per maintainer: bug already fixed by upstream commit b714a44 (#8076), no separate regression test needed.

@soyuka soyuka closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant