mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +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\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\InlineFragmentNode;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Schema;
|
||||
use GraphQL\Utils;
|
||||
@ -138,6 +138,8 @@ class ResolveInfo
|
||||
$fragment = $this->fragments[$spreadName];
|
||||
$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 {
|
||||
width
|
||||
height
|
||||
...MyImage
|
||||
}
|
||||
replies {
|
||||
body
|
||||
@ -80,6 +81,9 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
||||
pic {
|
||||
url
|
||||
width
|
||||
... on Image {
|
||||
height
|
||||
}
|
||||
}
|
||||
recentArticle {
|
||||
id
|
||||
@ -90,6 +94,9 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
}
|
||||
fragment MyImage on Image {
|
||||
url
|
||||
}
|
||||
';
|
||||
$expectedDefaultSelection = [
|
||||
'author' => true,
|
||||
@ -106,7 +113,8 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
||||
],
|
||||
'image' => [
|
||||
'width' => true,
|
||||
'height' => true
|
||||
'height' => true,
|
||||
'url' => true
|
||||
],
|
||||
'replies' => [
|
||||
'body' => true,
|
||||
@ -115,7 +123,8 @@ class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
||||
'name' => true,
|
||||
'pic' => [
|
||||
'url' => true,
|
||||
'width' => true
|
||||
'width' => true,
|
||||
'height' => true
|
||||
],
|
||||
'recentArticle' => [
|
||||
'id' => true,
|
||||
|
Loading…
Reference in New Issue
Block a user