Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyx committed Dec 2, 2024
1 parent 39e07e4 commit e0f9753
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 62 deletions.
44 changes: 22 additions & 22 deletions src/Type/Definition/ResolveInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public function __construct(
* $this->fieldName up to $depth levels.
*
* Example:
* query MyQuery{
* {
* root {
* id,
Expand All @@ -186,8 +185,8 @@ public function __construct(
* [
* 'id' => true,
* 'nested' => [
* nested1 => true,
* nested2 => true
* 'nested1' => true,
* 'nested2' => true
* ]
* ]
*
Expand Down Expand Up @@ -225,16 +224,15 @@ public function getFieldSelection(int $depth = 0): array
* containing the subfield of this field/alias. Each of those field have the same structure as described above.
*
* Example:
* query MyQuery{
* {
* root {
* id,
* id
* nested {
* nested1(myArg:1)
* nested1Bis:nested1
* nested1(myArg: 1)
* nested1Bis: nested1
* }
* alias1:nested {
* nested1(myArg:2, mySecondAg:"test")
* nested1(myArg: 2, mySecondAg: "test")
* }
* }
* }
Expand All @@ -245,36 +243,36 @@ public function getFieldSelection(int $depth = 0): array
* 'id' => [
* 'aliases' => [
* 'id' => [
* [args] => []
* 'args' => []
* ]
* ]
* ],
* 'nested' => [
* 'aliases' => [
* 'nested' => [
* ['args'] => [],
* ['fields'] => [
* 'args' => [],
* 'fields' => [
* 'nested1' => [
* 'aliases' => [
* 'nested1' => [
* ['args'] => [
* 'args' => [
* 'myArg' => 1
* ]
* ],
* 'nested1Bis' => [
* ['args'] => []
* 'args' => []
* ]
* ]
* ]
* ]
* ],
* 'alias1' => [
* ['args'] => [],
* ['fields'] => [
* 'args' => [],
* 'fields' => [
* 'nested1' => [
* 'aliases' => [
* 'nested1' => [
* ['args'] => [
* 'args' => [
* 'myArg' => 2,
* 'mySecondAg' => "test"
* ]
Expand All @@ -292,18 +290,17 @@ public function getFieldSelection(int $depth = 0): array
* You still can alias the union type fields with the same name in order to extract their corresponding args.
*
* Example:
* query MyQuery{
* {
* root {
* id,
* id
* unionPerson {
* ...on Child {
* name
* birthdate(format:"d/m/Y")
* birthdate(format: "d/m/Y")
* }
* ...on Adult {
* adultName:name
* adultBirthDate:birthdate(format:"Y-m-d")
* adultName: name
* adultBirthDate:birthdate(format: "Y-m-d")
* job
* }
* }
Expand Down Expand Up @@ -411,7 +408,10 @@ private function foldSelectionWithAlias(SelectionSetNode $selectionSet, int $des
assert($parentType instanceof HasFieldsType, 'ensured by query validation and the check above which excludes union types');

$fieldDef = $parentType->getField($fieldName);
$fieldType = Type::getNamedType($fieldDef->getType());
$fieldType = $fieldDef->getType();
if ($fieldType instanceof WrappingType) {
$fieldType = $fieldType->getInnermostType();

Check warning on line 413 in src/Type/Definition/ResolveInfo.php

View check run for this annotation

Codecov / codecov/patch

src/Type/Definition/ResolveInfo.php#L413

Added line #L413 was not covered by tests
}
$fields[$fieldName]['aliases'][$aliasName]['args'] = Values::getArgumentValues($fieldDef, $selectionNode, $this->variableValues);

if ($descend > 0 && $selectionNode->selectionSet !== null) {
Expand Down
Loading

0 comments on commit e0f9753

Please sign in to comment.