Skip to content

Fix recursive merging of alias-aware field selections - #1997

Draft
developerjillur wants to merge 1 commit into
webonyx:masterfrom
developerjillur:fix-alias-selection-recursion
Draft

developerjillur wants to merge 1 commit into
webonyx:masterfrom
developerjillur:fix-alias-selection-recursion

Conversation

@developerjillur

Copy link
Copy Markdown

Fixes #1767

Repeated selections in getFieldSelectionWithAliases() currently pass Type instances through array_merge_recursive(). This converts them into arrays and can recurse into cyclic type configurations. It also combines repeated scalar/list argument values instead of preserving their original shape.

Use array_replace_recursive() for the alias-aware selection merges and combine nested selection sets when a field is repeated. This retains the original type instances, arguments, and selected subfields. Add twelve regression cases covering named and inline fragments in either order, duplicate root and nested fields, and cyclic object configurations.

Validation

  • All six non-cyclic regression cases fail against the original source.
  • composer test -- tests/Type/ResolveInfoTest.php: 19 tests, 128 assertions, passing, including all twelve new cases.
  • composer test: exit 0; 2101 tests, 738804 assertions. PHP 8.5.7 reports 3 warnings, 1 PHPUnit deprecation, 14 skipped and 4 incomplete tests. A task-local 512 MB PHP limit was used because the default 128 MB limit is insufficient for the existing large validator test.
  • composer stan -- --no-progress --memory-limit=512M --debug: no errors.
  • Rector dry run and local sequential php-cs-fixer dry run: clean on both changed files. The Docker-based formatter target was not run.
  • git diff --check: clean.

Changelog

Fixed

  • Preserve type instances, arguments and nested selections when merging repeated fields in ResolveInfo::getFieldSelectionWithAliases()

This branch has not been deployed

No deployments
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.

Usage of array_merge_recursive in ResolveInfo can lead to infinite recursion

1 participant