Repository navigation
Preserve unaliasedPath and rawVariableValues in ResolveInfo - #2831
officialasishkumar wants to merge 1 commit into
Conversation
Lighthouse wraps the `ResolveInfo` of webonyx/graphql-php in its own subclass before passing it to resolvers, but only forwarded the constructor arguments that existed in the first release of webonyx/graphql-php 15. Properties added later were reset to their defaults: - `unaliasedPath` (webonyx/graphql-php 15.12) was always an empty array - `rawVariableValues` (webonyx/graphql-php 15.43) was always null Copy both from the original `ResolveInfo` when they are set, so they hold the same values as in plain webonyx/graphql-php resolvers. Lighthouse still supports every webonyx/graphql-php ^15 release and PHP 8.0, which cannot spread named arguments conditionally, so the values are assigned after calling the parent constructor. The `isset()` guards keep this cheap, since it runs for every resolved field. Resolves nuwave#2650
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The failing |
Resolves #2650
Changes
Lighthouse wraps the
ResolveInfoof webonyx/graphql-php in its own subclass before passing it to resolvers.It only forwarded the constructor arguments of the first webonyx/graphql-php 15 release, so properties added later were reset to their defaults:
unaliasedPath(webonyx/graphql-php 15.12) was always[]rawVariableValues(webonyx/graphql-php 15.43) was alwaysnullBoth are now copied from the original
ResolveInfowhen they are set, so resolvers see the same values as in plain webonyx/graphql-php.As discussed in the issue, this keeps supporting every webonyx/graphql-php ^15 release, with TODOs to pass the values to the parent constructor once a newer minimum is required.
Spreading named arguments conditionally needs PHP 8.1, so the values are assigned after the parent constructor instead.
The
isset()guards are cheap, which matters because this runs for every resolved field.On older webonyx/graphql-php versions the properties do not exist, so the guards skip them and the tests are skipped.
I checked PHPStan and the tests against webonyx/graphql-php 15.0.0, 15.12.0 and the latest release.
maxLookAheadFields(webonyx/graphql-php 15.50) is left out on purpose.Lighthouse does not pass execution options to webonyx/graphql-php, so the original
ResolveInfoalways holds the default that the parent constructor sets anyway.Breaking changes
None.
Changelog
Fixed
unaliasedPathandrawVariableValuesof webonyx/graphql-php in theResolveInfopassed to resolvers