-
-
Notifications
You must be signed in to change notification settings - Fork 565
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 method getFieldSelectionWithAliases
to class ResolveInfo
#1648
Conversation
…veInfo::lookAhead()
…t aliased at the same time.
I've made a few changes in order to manage the case where we have a field which is not aliased and the same one aliased. |
Please add tests. |
After writing some tests I have seen an edge case and completely refactored the code and moved it somewhere else. |
…nfo->lookAhead()->aliasArgs() to $info->getFieldSelectionWithAlias() Add tests
I switched the feature from $info->lookAhead()->aliasArgs() to $info->getFieldSelectionWithAlias() composer check is ok except for : Parameter #3 $parentType of method GraphQL\Type\Definition\ResolveInfo::foldSelectionWithAlias() expects GraphQL\Type\Definition\Type, (GraphQL\Type\Definition\NamedType&GraphQL\Type\Definition\Type)|null given But I can't set this typing definition if we want to keep the lib usable with php 7.4 as described in composer.json I am not familiar with open-source pull-requests. |
The PHPStan error should be fixable with an |
Updated |
I know I originally proposed it like this in #1072 (comment), but there we also included the type name per field. Given we no longer need that, is there any reason why we should nest aliases under a key [
'level2' => [
'aliases' => [
'level2000' => [
'args' => [
'width' => 1,
'height' => 1,
],
],
'level2' => [
'args' => [
'width' => 2,
'height' => 20,
],
],
],
],
] Or can we simplify like this? [
'level2' => [
'level2000' => [
'args' => [
'width' => 1,
'height' => 1,
],
],
'level2' => [
'args' => [
'width' => 2,
'height' => 20,
],
],
],
] |
Yes, in current state, we can simplify this If it's ok with you, I can add this line to the code: This will return if you keep the types described in tests :
|
Apparently, Adding the type name is kind of an arbitrary extra information anyways. Nullability or being in a list could also matter - as could other information about the field or the schema at that point. |
Yes, that was my point (evolution): if latter we need more information, it would have been easy to add it alongside the "aliases" level. Once removed, we won't be able to add field related informations without introducing breaking changes. |
We can always add a new API if something more complex is necessary. Let's keep the simple things simple and only add complexity when it is really necessary. |
I renamed the nested |
getFieldSelectionWithAliases
to class ResolveInfo
Thank you @zephyx, released with https://github.com/webonyx/graphql-php/releases/tag/v15.19.0. |
@see #1072
That was the simplest way to solve this issue with minimal breaking change due to the presence of $this->arrayMergeDeep(...).
If you have a better idea, no problem, I just needed this feature in my application.
NOTE: composer fix / check have updated several files but I have not modified them, so they are not included here.