Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unaliased path to resolve info #1548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Mar 24, 2024

Fixes #1345

@@ -75,7 +86,8 @@ public function __construct(
?array $positions = null,
?array $path = null,
?\Throwable $previous = null,
?array $extensions = null
?array $extensions = null,
?array $unaliasedPath = null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to put this at the end to break BC.

Comment on lines +1353 to +1363
$fieldNodes = $fields[$responseName];
assert($fieldNodes instanceof \ArrayObject, 'The keys of $fields populate $responseName');

$fieldPath = $path;
$fieldPath[] = $responseName;
$result = $this->resolveField($parentType, $rootValue, $fieldNodes, $fieldPath, $this->maybeScopeContext($contextValue));

$fieldNode = $fieldNodes[0];
assert($fieldNode instanceof FieldNode, '$fieldNodes is non-empty');

$fieldUnaliasedPath = $unaliasedPath;
$fieldUnaliasedPath[] = $fieldNode->name->value;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as executeFieldsSerially

Comment on lines +588 to +594
* @param mixed $rootValue
* @param array<int, string|int> $path
* @param array<int, string|int> $unaliasedPath
* @param mixed $contextValue
*
* @phpstan-param Path $path
* @phpstan-param Path $path
* @phpstan-param Path $unaliasedPath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if phpdoc_align was set to left, to not cause all these changes.

https://cs.symfony.com/doc/rules/phpdoc/phpdoc_align.html

* Returns an array describing the path from the root value to the field which produced this error.
* Only included for execution errors. This will never include aliases.
*
* @return array<int, int|string>|null
Copy link
Contributor Author

@ruudk ruudk Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it array<int, int|string> to be the same as path, but personally I would make this a list<int|string>.

@ruudk
Copy link
Contributor Author

ruudk commented Mar 26, 2024

@spawnia This one is ready for review, when you have time.

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.

Add real path to ResolveInfo
1 participant