nuwave / nuwave/lighthouse

New `unaliasedPath` field in `ResolveInfo` is removed when constructing Lighthouse `ResolveInfo`

Open
#2,650 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

Describe the bug
Since version 15.12 of webonyx/graphql-php there has been a new property on the ResolveInfo class, unaliasedPath.
This field is not preserved when building the child ResolveInfo class used by Lighthouse.

Expected behavior/Solution
The unaliasedPath property can be passed up through the parent constructor.

I am happy to create a PR, but I just want some guidance on how it should be done regarding the versioning.

Option 1:

Pass the unaliasedPath constructor parameter to the parent without checking, and force people to use the correct version of webonyx/graphql:

Nuwave\Lighthouse\Execution\ResolveInfo.php

     public function __construct(
         BaseResolveInfo $baseResolveInfo,
         public ArgumentSet $argumentSet,
     ) {
         parent::__construct(
             fieldDefinition: $baseResolveInfo->fieldDefinition,
             fieldNodes: $baseResolveInfo->fieldNodes,
             parentType: $baseResolveInfo->parentType,
             path: $baseResolveInfo->path,
            schema: $baseResolveInfo->schema,
             fragments: $baseResolveInfo->fragments,
             rootValue: $baseResolveInfo->rootValue,
             operation: $baseResolveInfo->operation,
             variableValues: $baseResolveInfo->variableValues,
+            unaliasedPath: $baseResolveInfo->unaliasedPath,
         );
     }

composer.json

     "require": {
         ...
-         "webonyx/graphql-php": "^15"
+         "webonyx/graphql-php": "^15.12.0"
     },

Option 2

Check if the property is set so it works with older versions. Something like this:

Nuwave\Lighthouse\Execution\ResolveInfo.php

     public function __construct(
         BaseResolveInfo $baseResolveInfo,
         public ArgumentSet $argumentSet,
     ) {
         parent::__construct(
             fieldDefinition: $baseResolveInfo->fieldDefinition,
             fieldNodes: $baseResolveInfo->fieldNodes,
             parentType: $baseResolveInfo->parentType,
             path: $baseResolveInfo->path,
            schema: $baseResolveInfo->schema,
             fragments: $baseResolveInfo->fragments,
             rootValue: $baseResolveInfo->rootValue,
             operation: $baseResolveInfo->operation,
             variableValues: $baseResolveInfo->variableValues,
+            ...(isset($baseResolveInfo->unaliasedPath)
+                ? ['unaliasedPath' => $baseResolveInfo->unaliasedPath]
+                : [])
         );
     }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Nuwave\Lighthouse\Execution\ResolveInfo.php and compare its parent constructor call with the webonyx/graphql-php 15.12 ResolveInfo signature. Check composer.json for the supported dependency range; the issue is done when child ResolveInfo instances preserve unaliasedPath while the chosen versioning approach remains compatible with the supported graphql-php versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.