mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-16 20:33:14 +03:00
ResolveInfo: Take in account inline fragments in getFieldSelection()
This commit is contained in:
parent
827bfa7907
commit
f77bd17eba
@ -5,8 +5,8 @@ use GraphQL\Error\InvariantViolation;
|
|||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\SelectionNode;
|
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Schema;
|
use GraphQL\Schema;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
@ -138,6 +138,8 @@ class ResolveInfo
|
|||||||
$fragment = $this->fragments[$spreadName];
|
$fragment = $this->fragments[$spreadName];
|
||||||
$fields += $this->foldSelectionSet($fragment->selectionSet, $descend);
|
$fields += $this->foldSelectionSet($fragment->selectionSet, $descend);
|
||||||
}
|
}
|
||||||
|
} else if ($selectionNode instanceof InlineFragmentNode) {
|
||||||
|
$fields += $this->foldSelectionSet($selectionNode->selectionSet, $descend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
|||||||
image {
|
image {
|
||||||
width
|
width
|
||||||
height
|
height
|
||||||
|
...MyImage
|
||||||
}
|
}
|
||||||
replies {
|
replies {
|
||||||
body
|
body
|
||||||
@ -80,6 +81,9 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
|||||||
pic {
|
pic {
|
||||||
url
|
url
|
||||||
width
|
width
|
||||||
|
... on Image {
|
||||||
|
height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recentArticle {
|
recentArticle {
|
||||||
id
|
id
|
||||||
@ -90,6 +94,9 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fragment MyImage on Image {
|
||||||
|
url
|
||||||
|
}
|
||||||
';
|
';
|
||||||
$expectedDefaultSelection = [
|
$expectedDefaultSelection = [
|
||||||
'author' => true,
|
'author' => true,
|
||||||
@ -106,7 +113,8 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
|||||||
],
|
],
|
||||||
'image' => [
|
'image' => [
|
||||||
'width' => true,
|
'width' => true,
|
||||||
'height' => true
|
'height' => true,
|
||||||
|
'url' => true
|
||||||
],
|
],
|
||||||
'replies' => [
|
'replies' => [
|
||||||
'body' => true,
|
'body' => true,
|
||||||
@ -115,7 +123,8 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
|||||||
'name' => true,
|
'name' => true,
|
||||||
'pic' => [
|
'pic' => [
|
||||||
'url' => true,
|
'url' => true,
|
||||||
'width' => true
|
'width' => true,
|
||||||
|
'height' => true
|
||||||
],
|
],
|
||||||
'recentArticle' => [
|
'recentArticle' => [
|
||||||
'id' => true,
|
'id' => true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user