mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 22:36:02 +03:00
GraphQL\Language\AST\NodeType -> GraphQL\Language\AST\NodeKind
This commit is contained in:
parent
7340e30753
commit
660200ed50
@ -7,7 +7,7 @@ use GraphQL\Language\AST\DocumentNode;
|
|||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Schema;
|
use GraphQL\Schema;
|
||||||
@ -119,7 +119,7 @@ class Executor
|
|||||||
|
|
||||||
foreach ($documentNode->definitions as $definition) {
|
foreach ($documentNode->definitions as $definition) {
|
||||||
switch ($definition->kind) {
|
switch ($definition->kind) {
|
||||||
case NodeType::OPERATION_DEFINITION:
|
case NodeKind::OPERATION_DEFINITION:
|
||||||
if (!$operationName && $operation) {
|
if (!$operationName && $operation) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Must provide operation name if query contains multiple operations.'
|
'Must provide operation name if query contains multiple operations.'
|
||||||
@ -130,7 +130,7 @@ class Executor
|
|||||||
$operation = $definition;
|
$operation = $definition;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NodeType::FRAGMENT_DEFINITION:
|
case NodeKind::FRAGMENT_DEFINITION:
|
||||||
$fragments[$definition->name->value] = $definition;
|
$fragments[$definition->name->value] = $definition;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -271,7 +271,7 @@ class Executor
|
|||||||
{
|
{
|
||||||
foreach ($selectionSet->selections as $selection) {
|
foreach ($selectionSet->selections as $selection) {
|
||||||
switch ($selection->kind) {
|
switch ($selection->kind) {
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
if (!self::shouldIncludeNode($exeContext, $selection->directives)) {
|
if (!self::shouldIncludeNode($exeContext, $selection->directives)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ class Executor
|
|||||||
}
|
}
|
||||||
$fields[$name][] = $selection;
|
$fields[$name][] = $selection;
|
||||||
break;
|
break;
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
if (!self::shouldIncludeNode($exeContext, $selection->directives) ||
|
if (!self::shouldIncludeNode($exeContext, $selection->directives) ||
|
||||||
!self::doesFragmentConditionMatch($exeContext, $selection, $runtimeType)
|
!self::doesFragmentConditionMatch($exeContext, $selection, $runtimeType)
|
||||||
) {
|
) {
|
||||||
@ -295,7 +295,7 @@ class Executor
|
|||||||
$visitedFragmentNames
|
$visitedFragmentNames
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case NodeType::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
$fragName = $selection->name->value;
|
$fragName = $selection->name->value;
|
||||||
if (!empty($visitedFragmentNames[$fragName]) || !self::shouldIncludeNode($exeContext, $selection->directives)) {
|
if (!empty($visitedFragmentNames[$fragName]) || !self::shouldIncludeNode($exeContext, $selection->directives)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ArgumentNode extends Node
|
class ArgumentNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::ARGUMENT;
|
public $kind = NodeKind::ARGUMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ValueNode
|
* @var ValueNode
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class BooleanValueNode extends Node implements ValueNode
|
class BooleanValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::BOOLEAN;
|
public $kind = NodeKind::BOOLEAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::DIRECTIVE_DEFINITION;
|
public $kind = NodeKind::DIRECTIVE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class DirectiveNode extends Node
|
class DirectiveNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::DIRECTIVE;
|
public $kind = NodeKind::DIRECTIVE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class DocumentNode extends Node
|
class DocumentNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::DOCUMENT;
|
public $kind = NodeKind::DOCUMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DefinitionNode[]
|
* @var DefinitionNode[]
|
||||||
|
@ -6,7 +6,7 @@ class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::ENUM_TYPE_DEFINITION;
|
public $kind = NodeKind::ENUM_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -6,7 +6,7 @@ class EnumValueDefinitionNode extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::ENUM_VALUE_DEFINITION;
|
public $kind = NodeKind::ENUM_VALUE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class EnumValueNode extends Node implements ValueNode
|
class EnumValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::ENUM;
|
public $kind = NodeKind::ENUM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class FieldDefinitionNode extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::FIELD_DEFINITION;
|
public $kind = NodeKind::FIELD_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class FieldNode extends Node implements SelectionNode
|
class FieldNode extends Node implements SelectionNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::FIELD;
|
public $kind = NodeKind::FIELD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class FloatValueNode extends Node implements ValueNode
|
class FloatValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::FLOAT;
|
public $kind = NodeKind::FLOAT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||||
{
|
{
|
||||||
public $kind = NodeType::FRAGMENT_DEFINITION;
|
public $kind = NodeKind::FRAGMENT_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class FragmentSpreadNode extends Node implements SelectionNode
|
class FragmentSpreadNode extends Node implements SelectionNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::FRAGMENT_SPREAD;
|
public $kind = NodeKind::FRAGMENT_SPREAD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class InlineFragmentNode extends Node implements SelectionNode
|
class InlineFragmentNode extends Node implements SelectionNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::INLINE_FRAGMENT;
|
public $kind = NodeKind::INLINE_FRAGMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NamedTypeNode
|
* @var NamedTypeNode
|
||||||
|
@ -6,7 +6,7 @@ class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION;
|
public $kind = NodeKind::INPUT_OBJECT_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -6,7 +6,7 @@ class InputValueDefinitionNode extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::INPUT_VALUE_DEFINITION;
|
public $kind = NodeKind::INPUT_VALUE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class IntValueNode extends Node implements ValueNode
|
class IntValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::INT;
|
public $kind = NodeKind::INT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::INTERFACE_TYPE_DEFINITION;
|
public $kind = NodeKind::INTERFACE_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ListTypeNode extends Node implements TypeNode
|
class ListTypeNode extends Node implements TypeNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::LIST_TYPE;
|
public $kind = NodeKind::LIST_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Node
|
* @var Node
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ListValueNode extends Node implements ValueNode
|
class ListValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::LST;
|
public $kind = NodeKind::LST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ValueNode[]
|
* @var ValueNode[]
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NameNode extends Node implements TypeNode
|
class NameNode extends Node implements TypeNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::NAME;
|
public $kind = NodeKind::NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NamedTypeNode extends Node implements TypeNode
|
class NamedTypeNode extends Node implements TypeNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::NAMED_TYPE;
|
public $kind = NodeKind::NAMED_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
class NodeType
|
class NodeKind
|
||||||
{
|
{
|
||||||
// constants from language/kinds.js:
|
// constants from language/kinds.js:
|
||||||
|
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NonNullTypeNode extends Node implements TypeNode
|
class NonNullTypeNode extends Node implements TypeNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::NON_NULL_TYPE;
|
public $kind = NodeKind::NON_NULL_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode | ListTypeNode
|
* @var NameNode | ListTypeNode
|
||||||
|
@ -3,5 +3,5 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NullValueNode extends Node implements ValueNode
|
class NullValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::NULL;
|
public $kind = NodeKind::NULL;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ObjectFieldNode extends Node
|
class ObjectFieldNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::OBJECT_FIELD;
|
public $kind = NodeKind::OBJECT_FIELD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -6,7 +6,7 @@ class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::OBJECT_TYPE_DEFINITION;
|
public $kind = NodeKind::OBJECT_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ObjectValueNode extends Node implements ValueNode
|
class ObjectValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::OBJECT;
|
public $kind = NodeKind::OBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ObjectFieldNode[]
|
* @var ObjectFieldNode[]
|
||||||
|
@ -6,7 +6,7 @@ class OperationDefinitionNode extends Node implements DefinitionNode, HasSelecti
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::OPERATION_DEFINITION;
|
public $kind = NodeKind::OPERATION_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -6,7 +6,7 @@ class OperationTypeDefinitionNode extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::OPERATION_TYPE_DEFINITION;
|
public $kind = NodeKind::OPERATION_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One of 'query' | 'mutation' | 'subscription'
|
* One of 'query' | 'mutation' | 'subscription'
|
||||||
|
@ -6,7 +6,7 @@ class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::SCALAR_TYPE_DEFINITION;
|
public $kind = NodeKind::SCALAR_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -6,7 +6,7 @@ class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::SCHEMA_DEFINITION;
|
public $kind = NodeKind::SCHEMA_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DirectiveNode[]
|
* @var DirectiveNode[]
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class SelectionSetNode extends Node
|
class SelectionSetNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::SELECTION_SET;
|
public $kind = NodeKind::SELECTION_SET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SelectionNode[]
|
* @var SelectionNode[]
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class StringValueNode extends Node implements ValueNode
|
class StringValueNode extends Node implements ValueNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::STRING;
|
public $kind = NodeKind::STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class TypeExtensionDefinitionNode extends Node implements TypeSystemDefinitionNo
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::TYPE_EXTENSION_DEFINITION;
|
public $kind = NodeKind::TYPE_EXTENSION_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ObjectTypeDefinitionNode
|
* @var ObjectTypeDefinitionNode
|
||||||
|
@ -6,7 +6,7 @@ class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = NodeType::UNION_TYPE_DEFINITION;
|
public $kind = NodeKind::UNION_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class VariableDefinitionNode extends Node implements DefinitionNode
|
class VariableDefinitionNode extends Node implements DefinitionNode
|
||||||
{
|
{
|
||||||
public $kind = NodeType::VARIABLE_DEFINITION;
|
public $kind = NodeKind::VARIABLE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var VariableNode
|
* @var VariableNode
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class VariableNode extends Node
|
class VariableNode extends Node
|
||||||
{
|
{
|
||||||
public $kind = NodeType::VARIABLE;
|
public $kind = NodeKind::VARIABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NameNode
|
* @var NameNode
|
||||||
|
@ -23,7 +23,7 @@ use GraphQL\Language\AST\IntValueNode;
|
|||||||
use GraphQL\Language\AST\ListTypeNode;
|
use GraphQL\Language\AST\ListTypeNode;
|
||||||
use GraphQL\Language\AST\NamedTypeNode;
|
use GraphQL\Language\AST\NamedTypeNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\NonNullTypeNode;
|
use GraphQL\Language\AST\NonNullTypeNode;
|
||||||
use GraphQL\Language\AST\NullValueNode;
|
use GraphQL\Language\AST\NullValueNode;
|
||||||
use GraphQL\Language\AST\ObjectFieldNode;
|
use GraphQL\Language\AST\ObjectFieldNode;
|
||||||
@ -55,16 +55,16 @@ class Printer
|
|||||||
{
|
{
|
||||||
return Visitor::visit($ast, [
|
return Visitor::visit($ast, [
|
||||||
'leave' => [
|
'leave' => [
|
||||||
NodeType::NAME => function(Node $node) {
|
NodeKind::NAME => function(Node $node) {
|
||||||
return '' . $node->value;
|
return '' . $node->value;
|
||||||
},
|
},
|
||||||
NodeType::VARIABLE => function($node) {
|
NodeKind::VARIABLE => function($node) {
|
||||||
return '$' . $node->name;
|
return '$' . $node->name;
|
||||||
},
|
},
|
||||||
NodeType::DOCUMENT => function(DocumentNode $node) {
|
NodeKind::DOCUMENT => function(DocumentNode $node) {
|
||||||
return $this->join($node->definitions, "\n\n") . "\n";
|
return $this->join($node->definitions, "\n\n") . "\n";
|
||||||
},
|
},
|
||||||
NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) {
|
NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) {
|
||||||
$op = $node->operation;
|
$op = $node->operation;
|
||||||
$name = $node->name;
|
$name = $node->name;
|
||||||
$varDefs = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');
|
$varDefs = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')');
|
||||||
@ -76,28 +76,28 @@ class Printer
|
|||||||
? $selectionSet
|
? $selectionSet
|
||||||
: $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');
|
: $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');
|
||||||
},
|
},
|
||||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) {
|
NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) {
|
||||||
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
|
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
|
||||||
},
|
},
|
||||||
NodeType::SELECTION_SET => function(SelectionSetNode $node) {
|
NodeKind::SELECTION_SET => function(SelectionSetNode $node) {
|
||||||
return $this->block($node->selections);
|
return $this->block($node->selections);
|
||||||
},
|
},
|
||||||
NodeType::FIELD => function(FieldNode $node) {
|
NodeKind::FIELD => function(FieldNode $node) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
$this->wrap('', $node->alias, ': ') . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'),
|
$this->wrap('', $node->alias, ': ') . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'),
|
||||||
$this->join($node->directives, ' '),
|
$this->join($node->directives, ' '),
|
||||||
$node->selectionSet
|
$node->selectionSet
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::ARGUMENT => function(ArgumentNode $node) {
|
NodeKind::ARGUMENT => function(ArgumentNode $node) {
|
||||||
return $node->name . ': ' . $node->value;
|
return $node->name . ': ' . $node->value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fragments
|
// Fragments
|
||||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) {
|
NodeKind::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) {
|
||||||
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
|
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
|
||||||
},
|
},
|
||||||
NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) {
|
NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
"...",
|
"...",
|
||||||
$this->wrap('on ', $node->typeCondition),
|
$this->wrap('on ', $node->typeCondition),
|
||||||
@ -105,73 +105,73 @@ class Printer
|
|||||||
$node->selectionSet
|
$node->selectionSet
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
|
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
|
||||||
return "fragment {$node->name} on {$node->typeCondition} "
|
return "fragment {$node->name} on {$node->typeCondition} "
|
||||||
. $this->wrap('', $this->join($node->directives, ' '), ' ')
|
. $this->wrap('', $this->join($node->directives, ' '), ' ')
|
||||||
. $node->selectionSet;
|
. $node->selectionSet;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
NodeType::INT => function(IntValueNode $node) {
|
NodeKind::INT => function(IntValueNode $node) {
|
||||||
return $node->value;
|
return $node->value;
|
||||||
},
|
},
|
||||||
NodeType::FLOAT => function(FloatValueNode $node) {
|
NodeKind::FLOAT => function(FloatValueNode $node) {
|
||||||
return $node->value;
|
return $node->value;
|
||||||
},
|
},
|
||||||
NodeType::STRING => function(StringValueNode $node) {
|
NodeKind::STRING => function(StringValueNode $node) {
|
||||||
return json_encode($node->value);
|
return json_encode($node->value);
|
||||||
},
|
},
|
||||||
NodeType::BOOLEAN => function(BooleanValueNode $node) {
|
NodeKind::BOOLEAN => function(BooleanValueNode $node) {
|
||||||
return $node->value ? 'true' : 'false';
|
return $node->value ? 'true' : 'false';
|
||||||
},
|
},
|
||||||
NodeType::NULL => function(NullValueNode $node) {
|
NodeKind::NULL => function(NullValueNode $node) {
|
||||||
return 'null';
|
return 'null';
|
||||||
},
|
},
|
||||||
NodeType::ENUM => function(EnumValueNode $node) {
|
NodeKind::ENUM => function(EnumValueNode $node) {
|
||||||
return $node->value;
|
return $node->value;
|
||||||
},
|
},
|
||||||
NodeType::LST => function(ListValueNode $node) {
|
NodeKind::LST => function(ListValueNode $node) {
|
||||||
return '[' . $this->join($node->values, ', ') . ']';
|
return '[' . $this->join($node->values, ', ') . ']';
|
||||||
},
|
},
|
||||||
NodeType::OBJECT => function(ObjectValueNode $node) {
|
NodeKind::OBJECT => function(ObjectValueNode $node) {
|
||||||
return '{' . $this->join($node->fields, ', ') . '}';
|
return '{' . $this->join($node->fields, ', ') . '}';
|
||||||
},
|
},
|
||||||
NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) {
|
NodeKind::OBJECT_FIELD => function(ObjectFieldNode $node) {
|
||||||
return $node->name . ': ' . $node->value;
|
return $node->name . ': ' . $node->value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// DirectiveNode
|
// DirectiveNode
|
||||||
NodeType::DIRECTIVE => function(DirectiveNode $node) {
|
NodeKind::DIRECTIVE => function(DirectiveNode $node) {
|
||||||
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
|
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
NodeType::NAMED_TYPE => function(NamedTypeNode $node) {
|
NodeKind::NAMED_TYPE => function(NamedTypeNode $node) {
|
||||||
return $node->name;
|
return $node->name;
|
||||||
},
|
},
|
||||||
NodeType::LIST_TYPE => function(ListTypeNode $node) {
|
NodeKind::LIST_TYPE => function(ListTypeNode $node) {
|
||||||
return '[' . $node->type . ']';
|
return '[' . $node->type . ']';
|
||||||
},
|
},
|
||||||
NodeType::NON_NULL_TYPE => function(NonNullTypeNode $node) {
|
NodeKind::NON_NULL_TYPE => function(NonNullTypeNode $node) {
|
||||||
return $node->type . '!';
|
return $node->type . '!';
|
||||||
},
|
},
|
||||||
|
|
||||||
// Type System Definitions
|
// Type System Definitions
|
||||||
NodeType::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) {
|
NodeKind::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'schema',
|
'schema',
|
||||||
$this->join($def->directives, ' '),
|
$this->join($def->directives, ' '),
|
||||||
$this->block($def->operationTypes)
|
$this->block($def->operationTypes)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) {
|
NodeKind::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) {
|
||||||
return $def->operation . ': ' . $def->type;
|
return $def->operation . ': ' . $def->type;
|
||||||
},
|
},
|
||||||
|
|
||||||
NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinitionNode $def) {
|
NodeKind::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinitionNode $def) {
|
||||||
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
|
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
|
||||||
},
|
},
|
||||||
NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinitionNode $def) {
|
NodeKind::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'type',
|
'type',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -180,20 +180,20 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::FIELD_DEFINITION => function(FieldDefinitionNode $def) {
|
NodeKind::FIELD_DEFINITION => function(FieldDefinitionNode $def) {
|
||||||
return $def->name
|
return $def->name
|
||||||
. $this->wrap('(', $this->join($def->arguments, ', '), ')')
|
. $this->wrap('(', $this->join($def->arguments, ', '), ')')
|
||||||
. ': ' . $def->type
|
. ': ' . $def->type
|
||||||
. $this->wrap(' ', $this->join($def->directives, ' '));
|
. $this->wrap(' ', $this->join($def->directives, ' '));
|
||||||
},
|
},
|
||||||
NodeType::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) {
|
NodeKind::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
$def->name . ': ' . $def->type,
|
$def->name . ': ' . $def->type,
|
||||||
$this->wrap('= ', $def->defaultValue),
|
$this->wrap('= ', $def->defaultValue),
|
||||||
$this->join($def->directives, ' ')
|
$this->join($def->directives, ' ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinitionNode $def) {
|
NodeKind::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'interface',
|
'interface',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -201,7 +201,7 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::UNION_TYPE_DEFINITION => function(UnionTypeDefinitionNode $def) {
|
NodeKind::UNION_TYPE_DEFINITION => function(UnionTypeDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'union',
|
'union',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -209,7 +209,7 @@ class Printer
|
|||||||
'= ' . $this->join($def->types, ' | ')
|
'= ' . $this->join($def->types, ' | ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::ENUM_TYPE_DEFINITION => function(EnumTypeDefinitionNode $def) {
|
NodeKind::ENUM_TYPE_DEFINITION => function(EnumTypeDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'enum',
|
'enum',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -217,13 +217,13 @@ class Printer
|
|||||||
$this->block($def->values)
|
$this->block($def->values)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) {
|
NodeKind::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
$def->name,
|
$def->name,
|
||||||
$this->join($def->directives, ' ')
|
$this->join($def->directives, ' ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinitionNode $def) {
|
NodeKind::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinitionNode $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'input',
|
'input',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -231,10 +231,10 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) {
|
NodeKind::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) {
|
||||||
return "extend {$def->definition}";
|
return "extend {$def->definition}";
|
||||||
},
|
},
|
||||||
NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinitionNode $def) {
|
NodeKind::DIRECTIVE_DEFINITION => function(DirectiveDefinitionNode $def) {
|
||||||
return 'directive @' . $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')')
|
return 'directive @' . $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')')
|
||||||
. ' on ' . $this->join($def->locations, ' | ');
|
. ' on ' . $this->join($def->locations, ' | ');
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
namespace GraphQL\Language;
|
namespace GraphQL\Language;
|
||||||
|
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Utils\TypeInfo;
|
use GraphQL\Utils\TypeInfo;
|
||||||
|
|
||||||
class VisitorOperation
|
class VisitorOperation
|
||||||
@ -49,45 +49,45 @@ class Visitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static $visitorKeys = [
|
public static $visitorKeys = [
|
||||||
NodeType::NAME => [],
|
NodeKind::NAME => [],
|
||||||
NodeType::DOCUMENT => ['definitions'],
|
NodeKind::DOCUMENT => ['definitions'],
|
||||||
NodeType::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
NodeKind::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
||||||
NodeType::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'],
|
NodeKind::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'],
|
||||||
NodeType::VARIABLE => ['name'],
|
NodeKind::VARIABLE => ['name'],
|
||||||
NodeType::SELECTION_SET => ['selections'],
|
NodeKind::SELECTION_SET => ['selections'],
|
||||||
NodeType::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
NodeKind::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
||||||
NodeType::ARGUMENT => ['name', 'value'],
|
NodeKind::ARGUMENT => ['name', 'value'],
|
||||||
NodeType::FRAGMENT_SPREAD => ['name', 'directives'],
|
NodeKind::FRAGMENT_SPREAD => ['name', 'directives'],
|
||||||
NodeType::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'],
|
NodeKind::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'],
|
||||||
NodeType::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'],
|
NodeKind::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'],
|
||||||
|
|
||||||
NodeType::INT => [],
|
NodeKind::INT => [],
|
||||||
NodeType::FLOAT => [],
|
NodeKind::FLOAT => [],
|
||||||
NodeType::STRING => [],
|
NodeKind::STRING => [],
|
||||||
NodeType::BOOLEAN => [],
|
NodeKind::BOOLEAN => [],
|
||||||
NodeType::NULL => [],
|
NodeKind::NULL => [],
|
||||||
NodeType::ENUM => [],
|
NodeKind::ENUM => [],
|
||||||
NodeType::LST => ['values'],
|
NodeKind::LST => ['values'],
|
||||||
NodeType::OBJECT => ['fields'],
|
NodeKind::OBJECT => ['fields'],
|
||||||
NodeType::OBJECT_FIELD => ['name', 'value'],
|
NodeKind::OBJECT_FIELD => ['name', 'value'],
|
||||||
NodeType::DIRECTIVE => ['name', 'arguments'],
|
NodeKind::DIRECTIVE => ['name', 'arguments'],
|
||||||
NodeType::NAMED_TYPE => ['name'],
|
NodeKind::NAMED_TYPE => ['name'],
|
||||||
NodeType::LIST_TYPE => ['type'],
|
NodeKind::LIST_TYPE => ['type'],
|
||||||
NodeType::NON_NULL_TYPE => ['type'],
|
NodeKind::NON_NULL_TYPE => ['type'],
|
||||||
|
|
||||||
NodeType::SCHEMA_DEFINITION => ['directives', 'operationTypes'],
|
NodeKind::SCHEMA_DEFINITION => ['directives', 'operationTypes'],
|
||||||
NodeType::OPERATION_TYPE_DEFINITION => ['type'],
|
NodeKind::OPERATION_TYPE_DEFINITION => ['type'],
|
||||||
NodeType::SCALAR_TYPE_DEFINITION => ['name', 'directives'],
|
NodeKind::SCALAR_TYPE_DEFINITION => ['name', 'directives'],
|
||||||
NodeType::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'],
|
NodeKind::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'],
|
||||||
NodeType::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'],
|
NodeKind::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'],
|
||||||
NodeType::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'],
|
NodeKind::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'],
|
||||||
NodeType::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
NodeKind::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
||||||
NodeType::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ],
|
NodeKind::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ],
|
||||||
NodeType::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ],
|
NodeKind::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ],
|
||||||
NodeType::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ],
|
NodeKind::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ],
|
||||||
NodeType::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
NodeKind::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
||||||
NodeType::TYPE_EXTENSION_DEFINITION => [ 'definition' ],
|
NodeKind::TYPE_EXTENSION_DEFINITION => [ 'definition' ],
|
||||||
NodeType::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ]
|
NodeKind::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ use GraphQL\Language\AST\FieldNode;
|
|||||||
use GraphQL\Language\AST\ListTypeNode;
|
use GraphQL\Language\AST\ListTypeNode;
|
||||||
use GraphQL\Language\AST\NamedTypeNode;
|
use GraphQL\Language\AST\NamedTypeNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\NonNullTypeNode;
|
use GraphQL\Language\AST\NonNullTypeNode;
|
||||||
use GraphQL\Schema;
|
use GraphQL\Schema;
|
||||||
use GraphQL\Type\Definition\AbstractType;
|
use GraphQL\Type\Definition\AbstractType;
|
||||||
@ -310,7 +310,7 @@ class TypeInfo
|
|||||||
$schema = $this->schema;
|
$schema = $this->schema;
|
||||||
|
|
||||||
switch ($node->kind) {
|
switch ($node->kind) {
|
||||||
case NodeType::SELECTION_SET:
|
case NodeKind::SELECTION_SET:
|
||||||
$namedType = Type::getNamedType($this->getType());
|
$namedType = Type::getNamedType($this->getType());
|
||||||
$compositeType = null;
|
$compositeType = null;
|
||||||
if (Type::isCompositeType($namedType)) {
|
if (Type::isCompositeType($namedType)) {
|
||||||
@ -320,7 +320,7 @@ class TypeInfo
|
|||||||
$this->parentTypeStack[] = $compositeType; // push
|
$this->parentTypeStack[] = $compositeType; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
$parentType = $this->getParentType();
|
$parentType = $this->getParentType();
|
||||||
$fieldDef = null;
|
$fieldDef = null;
|
||||||
if ($parentType) {
|
if ($parentType) {
|
||||||
@ -330,11 +330,11 @@ class TypeInfo
|
|||||||
$this->typeStack[] = $fieldDef ? $fieldDef->getType() : null; // push
|
$this->typeStack[] = $fieldDef ? $fieldDef->getType() : null; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::DIRECTIVE:
|
case NodeKind::DIRECTIVE:
|
||||||
$this->directive = $schema->getDirective($node->name->value);
|
$this->directive = $schema->getDirective($node->name->value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::OPERATION_DEFINITION:
|
case NodeKind::OPERATION_DEFINITION:
|
||||||
$type = null;
|
$type = null;
|
||||||
if ($node->operation === 'query') {
|
if ($node->operation === 'query') {
|
||||||
$type = $schema->getQueryType();
|
$type = $schema->getQueryType();
|
||||||
@ -346,19 +346,19 @@ class TypeInfo
|
|||||||
$this->typeStack[] = $type; // push
|
$this->typeStack[] = $type; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
case NodeType::FRAGMENT_DEFINITION:
|
case NodeKind::FRAGMENT_DEFINITION:
|
||||||
$typeConditionNode = $node->typeCondition;
|
$typeConditionNode = $node->typeCondition;
|
||||||
$outputType = $typeConditionNode ? self::typeFromAST($schema, $typeConditionNode) : $this->getType();
|
$outputType = $typeConditionNode ? self::typeFromAST($schema, $typeConditionNode) : $this->getType();
|
||||||
$this->typeStack[] = $outputType; // push
|
$this->typeStack[] = $outputType; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::VARIABLE_DEFINITION:
|
case NodeKind::VARIABLE_DEFINITION:
|
||||||
$inputType = self::typeFromAST($schema, $node->type);
|
$inputType = self::typeFromAST($schema, $node->type);
|
||||||
$this->inputTypeStack[] = $inputType; // push
|
$this->inputTypeStack[] = $inputType; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::ARGUMENT:
|
case NodeKind::ARGUMENT:
|
||||||
$fieldOrDirective = $this->getDirective() ?: $this->getFieldDef();
|
$fieldOrDirective = $this->getDirective() ?: $this->getFieldDef();
|
||||||
$argDef = $argType = null;
|
$argDef = $argType = null;
|
||||||
if ($fieldOrDirective) {
|
if ($fieldOrDirective) {
|
||||||
@ -371,12 +371,12 @@ class TypeInfo
|
|||||||
$this->inputTypeStack[] = $argType; // push
|
$this->inputTypeStack[] = $argType; // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::LST:
|
case NodeKind::LST:
|
||||||
$listType = Type::getNullableType($this->getInputType());
|
$listType = Type::getNullableType($this->getInputType());
|
||||||
$this->inputTypeStack[] = ($listType instanceof ListOfType ? $listType->getWrappedType() : null); // push
|
$this->inputTypeStack[] = ($listType instanceof ListOfType ? $listType->getWrappedType() : null); // push
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::OBJECT_FIELD:
|
case NodeKind::OBJECT_FIELD:
|
||||||
$objectType = Type::getNamedType($this->getInputType());
|
$objectType = Type::getNamedType($this->getInputType());
|
||||||
$fieldType = null;
|
$fieldType = null;
|
||||||
if ($objectType instanceof InputObjectType) {
|
if ($objectType instanceof InputObjectType) {
|
||||||
@ -395,33 +395,33 @@ class TypeInfo
|
|||||||
function leave(Node $node)
|
function leave(Node $node)
|
||||||
{
|
{
|
||||||
switch ($node->kind) {
|
switch ($node->kind) {
|
||||||
case NodeType::SELECTION_SET:
|
case NodeKind::SELECTION_SET:
|
||||||
array_pop($this->parentTypeStack);
|
array_pop($this->parentTypeStack);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
array_pop($this->fieldDefStack);
|
array_pop($this->fieldDefStack);
|
||||||
array_pop($this->typeStack);
|
array_pop($this->typeStack);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::DIRECTIVE:
|
case NodeKind::DIRECTIVE:
|
||||||
$this->directive = null;
|
$this->directive = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::OPERATION_DEFINITION:
|
case NodeKind::OPERATION_DEFINITION:
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
case NodeType::FRAGMENT_DEFINITION:
|
case NodeKind::FRAGMENT_DEFINITION:
|
||||||
array_pop($this->typeStack);
|
array_pop($this->typeStack);
|
||||||
break;
|
break;
|
||||||
case NodeType::VARIABLE_DEFINITION:
|
case NodeKind::VARIABLE_DEFINITION:
|
||||||
array_pop($this->inputTypeStack);
|
array_pop($this->inputTypeStack);
|
||||||
break;
|
break;
|
||||||
case NodeType::ARGUMENT:
|
case NodeKind::ARGUMENT:
|
||||||
$this->argument = null;
|
$this->argument = null;
|
||||||
array_pop($this->inputTypeStack);
|
array_pop($this->inputTypeStack);
|
||||||
break;
|
break;
|
||||||
case NodeType::LST:
|
case NodeKind::LST:
|
||||||
case NodeType::OBJECT_FIELD:
|
case NodeKind::OBJECT_FIELD:
|
||||||
array_pop($this->inputTypeStack);
|
array_pop($this->inputTypeStack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use GraphQL\Language\AST\ListValueNode;
|
|||||||
use GraphQL\Language\AST\DocumentNode;
|
use GraphQL\Language\AST\DocumentNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\NullValueNode;
|
use GraphQL\Language\AST\NullValueNode;
|
||||||
use GraphQL\Language\AST\ValueNode;
|
use GraphQL\Language\AST\ValueNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
use GraphQL\Language\AST\VariableNode;
|
||||||
@ -195,7 +195,7 @@ class DocumentValidator
|
|||||||
|
|
||||||
// Input objects check each defined field and look for undefined fields.
|
// Input objects check each defined field and look for undefined fields.
|
||||||
if ($type instanceof InputObjectType) {
|
if ($type instanceof InputObjectType) {
|
||||||
if ($valueNode->kind !== NodeType::OBJECT) {
|
if ($valueNode->kind !== NodeKind::OBJECT) {
|
||||||
return [ "Expected \"{$type->name}\", found not an object." ];
|
return [ "Expected \"{$type->name}\", found not an object." ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use GraphQL\Language\AST\FragmentDefinitionNode;
|
|||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Type\Definition\Type;
|
use GraphQL\Type\Definition\Type;
|
||||||
use GraphQL\Type\Introspection;
|
use GraphQL\Type\Introspection;
|
||||||
@ -100,7 +100,7 @@ abstract class AbstractQuerySecurity
|
|||||||
|
|
||||||
foreach ($selectionSet->selections as $selection) {
|
foreach ($selectionSet->selections as $selection) {
|
||||||
switch ($selection->kind) {
|
switch ($selection->kind) {
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
/* @var FieldNode $selection */
|
/* @var FieldNode $selection */
|
||||||
$fieldName = $selection->name->value;
|
$fieldName = $selection->name->value;
|
||||||
$fieldDef = null;
|
$fieldDef = null;
|
||||||
@ -127,7 +127,7 @@ abstract class AbstractQuerySecurity
|
|||||||
// create field context
|
// create field context
|
||||||
$_astAndDefs[$responseName][] = [$selection, $fieldDef];
|
$_astAndDefs[$responseName][] = [$selection, $fieldDef];
|
||||||
break;
|
break;
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
/* @var InlineFragmentNode $selection */
|
/* @var InlineFragmentNode $selection */
|
||||||
$_astAndDefs = $this->collectFieldASTsAndDefs(
|
$_astAndDefs = $this->collectFieldASTsAndDefs(
|
||||||
$context,
|
$context,
|
||||||
@ -137,7 +137,7 @@ abstract class AbstractQuerySecurity
|
|||||||
$_astAndDefs
|
$_astAndDefs
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case NodeType::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
/* @var FragmentSpreadNode $selection */
|
/* @var FragmentSpreadNode $selection */
|
||||||
$fragName = $selection->name->value;
|
$fragName = $selection->name->value;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Type\Definition\NonNull;
|
use GraphQL\Type\Definition\NonNull;
|
||||||
@ -26,7 +26,7 @@ class ArgumentsOfCorrectType
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::ARGUMENT => function(ArgumentNode $argNode) use ($context) {
|
NodeKind::ARGUMENT => function(ArgumentNode $argNode) use ($context) {
|
||||||
$argDef = $context->getArgument();
|
$argDef = $context->getArgument();
|
||||||
if ($argDef) {
|
if ($argDef) {
|
||||||
$errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argNode->value);
|
$errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argNode->value);
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
@ -30,7 +30,7 @@ class DefaultValuesOfCorrectType
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) use ($context) {
|
NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) use ($context) {
|
||||||
$name = $varDefNode->variable->name->value;
|
$name = $varDefNode->variable->name->value;
|
||||||
$defaultValue = $varDefNode->defaultValue;
|
$defaultValue = $varDefNode->defaultValue;
|
||||||
$type = $context->getInputType();
|
$type = $context->getInputType();
|
||||||
@ -52,8 +52,8 @@ class DefaultValuesOfCorrectType
|
|||||||
}
|
}
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::SELECTION_SET => function() {return Visitor::skipNode();},
|
NodeKind::SELECTION_SET => function() {return Visitor::skipNode();},
|
||||||
NodeType::FRAGMENT_DEFINITION => function() {return Visitor::skipNode();}
|
NodeKind::FRAGMENT_DEFINITION => function() {return Visitor::skipNode();}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Schema;
|
use GraphQL\Schema;
|
||||||
use GraphQL\Type\Definition\AbstractType;
|
use GraphQL\Type\Definition\AbstractType;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
@ -37,7 +37,7 @@ class FieldsOnCorrectType
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::FIELD => function(FieldNode $node) use ($context) {
|
NodeKind::FIELD => function(FieldNode $node) use ($context) {
|
||||||
$type = $context->getParentType();
|
$type = $context->getParentType();
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$fieldDef = $context->getFieldDef();
|
$fieldDef = $context->getFieldDef();
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Type\Definition\CompositeType;
|
use GraphQL\Type\Definition\CompositeType;
|
||||||
use GraphQL\Type\Definition\Type;
|
use GraphQL\Type\Definition\Type;
|
||||||
@ -28,7 +28,7 @@ class FragmentsOnCompositeTypes
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
|
NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
|
||||||
$type = $context->getType();
|
$type = $context->getType();
|
||||||
|
|
||||||
if ($node->typeCondition && $type && !Type::isCompositeType($type)) {
|
if ($node->typeCondition && $type && !Type::isCompositeType($type)) {
|
||||||
@ -38,7 +38,7 @@ class FragmentsOnCompositeTypes
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
|
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
|
||||||
$type = $context->getType();
|
$type = $context->getType();
|
||||||
|
|
||||||
if ($type && !Type::isCompositeType($type)) {
|
if ($type && !Type::isCompositeType($type)) {
|
||||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\Messages;
|
use GraphQL\Validator\Messages;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -25,9 +25,9 @@ class KnownArgumentNames
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::ARGUMENT => function(ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
NodeKind::ARGUMENT => function(ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||||
$argumentOf = $ancestors[count($ancestors) - 1];
|
$argumentOf = $ancestors[count($ancestors) - 1];
|
||||||
if ($argumentOf->kind === NodeType::FIELD) {
|
if ($argumentOf->kind === NodeKind::FIELD) {
|
||||||
$fieldDef = $context->getFieldDef();
|
$fieldDef = $context->getFieldDef();
|
||||||
|
|
||||||
if ($fieldDef) {
|
if ($fieldDef) {
|
||||||
@ -47,7 +47,7 @@ class KnownArgumentNames
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($argumentOf->kind === NodeType::DIRECTIVE) {
|
} else if ($argumentOf->kind === NodeKind::DIRECTIVE) {
|
||||||
$directive = $context->getDirective();
|
$directive = $context->getDirective();
|
||||||
if ($directive) {
|
if ($directive) {
|
||||||
$directiveArgDef = null;
|
$directiveArgDef = null;
|
||||||
|
@ -9,7 +9,7 @@ use GraphQL\Language\AST\FragmentDefinitionNode;
|
|||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Validator\Messages;
|
use GraphQL\Validator\Messages;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -30,7 +30,7 @@ class KnownDirectives
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::DIRECTIVE => function (DirectiveNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
NodeKind::DIRECTIVE => function (DirectiveNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||||
$directiveDef = null;
|
$directiveDef = null;
|
||||||
foreach ($context->getSchema()->getDirectives() as $def) {
|
foreach ($context->getSchema()->getDirectives() as $def) {
|
||||||
if ($def->name === $node->name->value) {
|
if ($def->name === $node->name->value) {
|
||||||
@ -67,17 +67,17 @@ class KnownDirectives
|
|||||||
private function getLocationForAppliedNode(Node $appliedTo)
|
private function getLocationForAppliedNode(Node $appliedTo)
|
||||||
{
|
{
|
||||||
switch ($appliedTo->kind) {
|
switch ($appliedTo->kind) {
|
||||||
case NodeType::OPERATION_DEFINITION:
|
case NodeKind::OPERATION_DEFINITION:
|
||||||
switch ($appliedTo->operation) {
|
switch ($appliedTo->operation) {
|
||||||
case 'query': return DirectiveDef::LOCATION_QUERY;
|
case 'query': return DirectiveDef::LOCATION_QUERY;
|
||||||
case 'mutation': return DirectiveDef::LOCATION_MUTATION;
|
case 'mutation': return DirectiveDef::LOCATION_MUTATION;
|
||||||
case 'subscription': return DirectiveDef::LOCATION_SUBSCRIPTION;
|
case 'subscription': return DirectiveDef::LOCATION_SUBSCRIPTION;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NodeType::FIELD: return DirectiveDef::LOCATION_FIELD;
|
case NodeKind::FIELD: return DirectiveDef::LOCATION_FIELD;
|
||||||
case NodeType::FRAGMENT_SPREAD: return DirectiveDef::LOCATION_FRAGMENT_SPREAD;
|
case NodeKind::FRAGMENT_SPREAD: return DirectiveDef::LOCATION_FRAGMENT_SPREAD;
|
||||||
case NodeType::INLINE_FRAGMENT: return DirectiveDef::LOCATION_INLINE_FRAGMENT;
|
case NodeKind::INLINE_FRAGMENT: return DirectiveDef::LOCATION_INLINE_FRAGMENT;
|
||||||
case NodeType::FRAGMENT_DEFINITION: return DirectiveDef::LOCATION_FRAGMENT_DEFINITION;
|
case NodeKind::FRAGMENT_DEFINITION: return DirectiveDef::LOCATION_FRAGMENT_DEFINITION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class KnownFragmentNames
|
class KnownFragmentNames
|
||||||
@ -18,7 +18,7 @@ class KnownFragmentNames
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
NodeKind::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
||||||
$fragmentName = $node->name->value;
|
$fragmentName = $node->name->value;
|
||||||
$fragment = $context->getFragment($fragmentName);
|
$fragment = $context->getFragment($fragmentName);
|
||||||
if (!$fragment) {
|
if (!$fragment) {
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\NamedTypeNode;
|
use GraphQL\Language\AST\NamedTypeNode;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
@ -20,12 +20,12 @@ class KnownTypeNames
|
|||||||
$skip = function() {return Visitor::skipNode();};
|
$skip = function() {return Visitor::skipNode();};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OBJECT_TYPE_DEFINITION => $skip,
|
NodeKind::OBJECT_TYPE_DEFINITION => $skip,
|
||||||
NodeType::INTERFACE_TYPE_DEFINITION => $skip,
|
NodeKind::INTERFACE_TYPE_DEFINITION => $skip,
|
||||||
NodeType::UNION_TYPE_DEFINITION => $skip,
|
NodeKind::UNION_TYPE_DEFINITION => $skip,
|
||||||
NodeType::INPUT_OBJECT_TYPE_DEFINITION => $skip,
|
NodeKind::INPUT_OBJECT_TYPE_DEFINITION => $skip,
|
||||||
|
|
||||||
NodeType::NAMED_TYPE => function(NamedTypeNode $node, $key) use ($context) {
|
NodeKind::NAMED_TYPE => function(NamedTypeNode $node, $key) use ($context) {
|
||||||
$typeName = $node->name->value;
|
$typeName = $node->name->value;
|
||||||
$type = $context->getSchema()->getType($typeName);
|
$type = $context->getSchema()->getType($typeName);
|
||||||
if (!$type) {
|
if (!$type) {
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\DocumentNode;
|
use GraphQL\Language\AST\DocumentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -26,16 +26,16 @@ class LoneAnonymousOperation
|
|||||||
{
|
{
|
||||||
$operationCount = 0;
|
$operationCount = 0;
|
||||||
return [
|
return [
|
||||||
NodeType::DOCUMENT => function(DocumentNode $node) use (&$operationCount) {
|
NodeKind::DOCUMENT => function(DocumentNode $node) use (&$operationCount) {
|
||||||
$tmp = Utils::filter(
|
$tmp = Utils::filter(
|
||||||
$node->definitions,
|
$node->definitions,
|
||||||
function ($definition) {
|
function ($definition) {
|
||||||
return $definition->kind === NodeType::OPERATION_DEFINITION;
|
return $definition->kind === NodeKind::OPERATION_DEFINITION;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$operationCount = count($tmp);
|
$operationCount = count($tmp);
|
||||||
},
|
},
|
||||||
NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use (&$operationCount, $context) {
|
NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use (&$operationCount, $context) {
|
||||||
if (!$node->name && $operationCount > 1) {
|
if (!$node->name && $operationCount > 1) {
|
||||||
$context->reportError(
|
$context->reportError(
|
||||||
new Error(self::anonOperationNotAloneMessage(), [$node])
|
new Error(self::anonOperationNotAloneMessage(), [$node])
|
||||||
|
@ -13,7 +13,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -45,10 +45,10 @@ class NoFragmentCycles
|
|||||||
$this->spreadPathIndexByName = [];
|
$this->spreadPathIndexByName = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => function () {
|
NodeKind::OPERATION_DEFINITION => function () {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
||||||
if (!isset($this->visitedFrags[$node->name->value])) {
|
if (!isset($this->visitedFrags[$node->name->value])) {
|
||||||
$this->detectCycleRecursive($node, $context);
|
$this->detectCycleRecursive($node, $context);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
use GraphQL\Language\AST\VariableNode;
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
@ -36,7 +36,7 @@ class NoUndefinedVariables
|
|||||||
$variableNameDefined = [];
|
$variableNameDefined = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'enter' => function() use (&$variableNameDefined) {
|
'enter' => function() use (&$variableNameDefined) {
|
||||||
$variableNameDefined = [];
|
$variableNameDefined = [];
|
||||||
},
|
},
|
||||||
@ -59,7 +59,7 @@ class NoUndefinedVariables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $def) use (&$variableNameDefined) {
|
NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $def) use (&$variableNameDefined) {
|
||||||
$variableNameDefined[$def->variable->name->value] = true;
|
$variableNameDefined[$def->variable->name->value] = true;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\Messages;
|
use GraphQL\Validator\Messages;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -28,15 +28,15 @@ class NoUnusedFragments
|
|||||||
$this->fragmentDefs = [];
|
$this->fragmentDefs = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => function($node) {
|
NodeKind::OPERATION_DEFINITION => function($node) {
|
||||||
$this->operationDefs[] = $node;
|
$this->operationDefs[] = $node;
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) {
|
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) {
|
||||||
$this->fragmentDefs[] = $def;
|
$this->fragmentDefs[] = $def;
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::DOCUMENT => [
|
NodeKind::DOCUMENT => [
|
||||||
'leave' => function() use ($context) {
|
'leave' => function() use ($context) {
|
||||||
$fragmentNameUsed = [];
|
$fragmentNameUsed = [];
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\Messages;
|
use GraphQL\Validator\Messages;
|
||||||
@ -26,7 +26,7 @@ class NoUnusedVariables
|
|||||||
$this->variableDefs = [];
|
$this->variableDefs = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'enter' => function() {
|
'enter' => function() {
|
||||||
$this->variableDefs = [];
|
$this->variableDefs = [];
|
||||||
},
|
},
|
||||||
@ -52,7 +52,7 @@ class NoUnusedVariables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
NodeType::VARIABLE_DEFINITION => function($def) {
|
NodeKind::VARIABLE_DEFINITION => function($def) {
|
||||||
$this->variableDefs[] = $def;
|
$this->variableDefs[] = $def;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -10,7 +10,7 @@ use GraphQL\Language\AST\FragmentSpreadNode;
|
|||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\NamedTypeNode;
|
use GraphQL\Language\AST\NamedTypeNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Type\Definition\ListOfType;
|
use GraphQL\Type\Definition\ListOfType;
|
||||||
@ -54,7 +54,7 @@ class OverlappingFieldsCanBeMerged
|
|||||||
$this->comparedSet = new PairSet();
|
$this->comparedSet = new PairSet();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::SELECTION_SET => [
|
NodeKind::SELECTION_SET => [
|
||||||
// Note: we validate on the reverse traversal so deeper conflicts will be
|
// Note: we validate on the reverse traversal so deeper conflicts will be
|
||||||
// caught first, for clearer error messages.
|
// caught first, for clearer error messages.
|
||||||
'leave' => function(SelectionSetNode $selectionSet) use ($context) {
|
'leave' => function(SelectionSetNode $selectionSet) use ($context) {
|
||||||
@ -318,7 +318,7 @@ class OverlappingFieldsCanBeMerged
|
|||||||
$selection = $selectionSet->selections[$i];
|
$selection = $selectionSet->selections[$i];
|
||||||
|
|
||||||
switch ($selection->kind) {
|
switch ($selection->kind) {
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
$fieldName = $selection->name->value;
|
$fieldName = $selection->name->value;
|
||||||
$fieldDef = null;
|
$fieldDef = null;
|
||||||
if ($parentType && method_exists($parentType, 'getFields')) {
|
if ($parentType && method_exists($parentType, 'getFields')) {
|
||||||
@ -334,7 +334,7 @@ class OverlappingFieldsCanBeMerged
|
|||||||
}
|
}
|
||||||
$_astAndDefs[$responseName][] = [$parentType, $selection, $fieldDef];
|
$_astAndDefs[$responseName][] = [$parentType, $selection, $fieldDef];
|
||||||
break;
|
break;
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
$typeCondition = $selection->typeCondition;
|
$typeCondition = $selection->typeCondition;
|
||||||
$inlineFragmentType = $typeCondition
|
$inlineFragmentType = $typeCondition
|
||||||
? TypeInfo::typeFromAST($context->getSchema(), $typeCondition)
|
? TypeInfo::typeFromAST($context->getSchema(), $typeCondition)
|
||||||
@ -348,7 +348,7 @@ class OverlappingFieldsCanBeMerged
|
|||||||
$_astAndDefs
|
$_astAndDefs
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case NodeType::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
/** @var FragmentSpreadNode $selection */
|
/** @var FragmentSpreadNode $selection */
|
||||||
$fragName = $selection->name->value;
|
$fragName = $selection->name->value;
|
||||||
if (!empty($_visitedFragmentNames[$fragName])) {
|
if (!empty($_visitedFragmentNames[$fragName])) {
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
use GraphQL\Utils\TypeInfo;
|
use GraphQL\Utils\TypeInfo;
|
||||||
@ -26,7 +26,7 @@ class PossibleFragmentSpreads
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
|
NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
|
||||||
$fragType = $context->getType();
|
$fragType = $context->getType();
|
||||||
$parentType = $context->getParentType();
|
$parentType = $context->getParentType();
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class PossibleFragmentSpreads
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
NodeKind::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
||||||
$fragName = $node->name->value;
|
$fragName = $node->name->value;
|
||||||
$fragType = $this->getFragmentType($context, $fragName);
|
$fragType = $this->getFragmentType($context, $fragName);
|
||||||
$parentType = $context->getParentType();
|
$parentType = $context->getParentType();
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\DirectiveNode;
|
use GraphQL\Language\AST\DirectiveNode;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Type\Definition\NonNull;
|
use GraphQL\Type\Definition\NonNull;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
@ -27,7 +27,7 @@ class ProvidedNonNullArguments
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::FIELD => [
|
NodeKind::FIELD => [
|
||||||
'leave' => function(FieldNode $fieldNode) use ($context) {
|
'leave' => function(FieldNode $fieldNode) use ($context) {
|
||||||
$fieldDef = $context->getFieldDef();
|
$fieldDef = $context->getFieldDef();
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class ProvidedNonNullArguments
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
NodeType::DIRECTIVE => [
|
NodeKind::DIRECTIVE => [
|
||||||
'leave' => function(DirectiveNode $directiveNode) use ($context) {
|
'leave' => function(DirectiveNode $directiveNode) use ($context) {
|
||||||
$directiveDef = $context->getDirective();
|
$directiveDef = $context->getDirective();
|
||||||
if (!$directiveDef) {
|
if (!$directiveDef) {
|
||||||
|
@ -8,7 +8,7 @@ use GraphQL\Language\AST\FieldNode;
|
|||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
@ -78,7 +78,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
|||||||
return $this->invokeIfNeeded(
|
return $this->invokeIfNeeded(
|
||||||
$context,
|
$context,
|
||||||
[
|
[
|
||||||
NodeType::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) {
|
NodeKind::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) {
|
||||||
$this->fieldNodeAndDefs = $this->collectFieldASTsAndDefs(
|
$this->fieldNodeAndDefs = $this->collectFieldASTsAndDefs(
|
||||||
$context,
|
$context,
|
||||||
$context->getParentType(),
|
$context->getParentType(),
|
||||||
@ -87,11 +87,11 @@ class QueryComplexity extends AbstractQuerySecurity
|
|||||||
$this->fieldNodeAndDefs
|
$this->fieldNodeAndDefs
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
NodeType::VARIABLE_DEFINITION => function ($def) {
|
NodeKind::VARIABLE_DEFINITION => function ($def) {
|
||||||
$this->variableDefs[] = $def;
|
$this->variableDefs[] = $def;
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) {
|
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) {
|
||||||
$complexity = $this->fieldComplexity($operationDefinition, $complexity);
|
$complexity = $this->fieldComplexity($operationDefinition, $complexity);
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
|||||||
private function nodeComplexity(Node $node, $complexity = 0)
|
private function nodeComplexity(Node $node, $complexity = 0)
|
||||||
{
|
{
|
||||||
switch ($node->kind) {
|
switch ($node->kind) {
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
/* @var FieldNode $node */
|
/* @var FieldNode $node */
|
||||||
// default values
|
// default values
|
||||||
$args = [];
|
$args = [];
|
||||||
@ -148,7 +148,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
|||||||
$complexity += call_user_func_array($complexityFn, [$childrenComplexity, $args]);
|
$complexity += call_user_func_array($complexityFn, [$childrenComplexity, $args]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
/* @var InlineFragmentNode $node */
|
/* @var InlineFragmentNode $node */
|
||||||
// node has children?
|
// node has children?
|
||||||
if (isset($node->selectionSet)) {
|
if (isset($node->selectionSet)) {
|
||||||
@ -156,7 +156,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
/* @var FragmentSpreadNode $node */
|
/* @var FragmentSpreadNode $node */
|
||||||
$fragment = $this->getFragment($node);
|
$fragment = $this->getFragment($node);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use GraphQL\Language\AST\FieldNode;
|
|||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -50,7 +50,7 @@ class QueryDepth extends AbstractQuerySecurity
|
|||||||
return $this->invokeIfNeeded(
|
return $this->invokeIfNeeded(
|
||||||
$context,
|
$context,
|
||||||
[
|
[
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) {
|
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) {
|
||||||
$maxDepth = $this->fieldDepth($operationDefinition);
|
$maxDepth = $this->fieldDepth($operationDefinition);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class QueryDepth extends AbstractQuerySecurity
|
|||||||
private function nodeDepth(Node $node, $depth = 0, $maxDepth = 0)
|
private function nodeDepth(Node $node, $depth = 0, $maxDepth = 0)
|
||||||
{
|
{
|
||||||
switch ($node->kind) {
|
switch ($node->kind) {
|
||||||
case NodeType::FIELD:
|
case NodeKind::FIELD:
|
||||||
/* @var FieldNode $node */
|
/* @var FieldNode $node */
|
||||||
// node has children?
|
// node has children?
|
||||||
if (null !== $node->selectionSet) {
|
if (null !== $node->selectionSet) {
|
||||||
@ -96,7 +96,7 @@ class QueryDepth extends AbstractQuerySecurity
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::INLINE_FRAGMENT:
|
case NodeKind::INLINE_FRAGMENT:
|
||||||
/* @var InlineFragmentNode $node */
|
/* @var InlineFragmentNode $node */
|
||||||
// node has children?
|
// node has children?
|
||||||
if (null !== $node->selectionSet) {
|
if (null !== $node->selectionSet) {
|
||||||
@ -104,7 +104,7 @@ class QueryDepth extends AbstractQuerySecurity
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NodeType::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
/* @var FragmentSpreadNode $node */
|
/* @var FragmentSpreadNode $node */
|
||||||
$fragment = $this->getFragment($node);
|
$fragment = $this->getFragment($node);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Type\Definition\Type;
|
use GraphQL\Type\Definition\Type;
|
||||||
use GraphQL\Validator\Messages;
|
use GraphQL\Validator\Messages;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -25,7 +25,7 @@ class ScalarLeafs
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::FIELD => function(FieldNode $node) use ($context) {
|
NodeKind::FIELD => function(FieldNode $node) use ($context) {
|
||||||
$type = $context->getType();
|
$type = $context->getType();
|
||||||
if ($type) {
|
if ($type) {
|
||||||
if (Type::isLeafType($type)) {
|
if (Type::isLeafType($type)) {
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ class UniqueArgumentNames
|
|||||||
$this->knownArgNames = [];
|
$this->knownArgNames = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::FIELD => function () {
|
NodeKind::FIELD => function () {
|
||||||
$this->knownArgNames = [];;
|
$this->knownArgNames = [];;
|
||||||
},
|
},
|
||||||
NodeType::DIRECTIVE => function () {
|
NodeKind::DIRECTIVE => function () {
|
||||||
$this->knownArgNames = [];
|
$this->knownArgNames = [];
|
||||||
},
|
},
|
||||||
NodeType::ARGUMENT => function (ArgumentNode $node) use ($context) {
|
NodeKind::ARGUMENT => function (ArgumentNode $node) use ($context) {
|
||||||
$argName = $node->name->value;
|
$argName = $node->name->value;
|
||||||
if (!empty($this->knownArgNames[$argName])) {
|
if (!empty($this->knownArgNames[$argName])) {
|
||||||
$context->reportError(new Error(
|
$context->reportError(new Error(
|
||||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\Error;
|
|||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
@ -23,10 +23,10 @@ class UniqueFragmentNames
|
|||||||
$this->knownFragmentNames = [];
|
$this->knownFragmentNames = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => function () {
|
NodeKind::OPERATION_DEFINITION => function () {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
||||||
$fragmentName = $node->name->value;
|
$fragmentName = $node->name->value;
|
||||||
if (!empty($this->knownFragmentNames[$fragmentName])) {
|
if (!empty($this->knownFragmentNames[$fragmentName])) {
|
||||||
$context->reportError(new Error(
|
$context->reportError(new Error(
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\ObjectFieldNode;
|
use GraphQL\Language\AST\ObjectFieldNode;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -24,7 +24,7 @@ class UniqueInputFieldNames
|
|||||||
$this->knownNameStack = [];
|
$this->knownNameStack = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OBJECT => [
|
NodeKind::OBJECT => [
|
||||||
'enter' => function() {
|
'enter' => function() {
|
||||||
$this->knownNameStack[] = $this->knownNames;
|
$this->knownNameStack[] = $this->knownNames;
|
||||||
$this->knownNames = [];
|
$this->knownNames = [];
|
||||||
@ -33,7 +33,7 @@ class UniqueInputFieldNames
|
|||||||
$this->knownNames = array_pop($this->knownNameStack);
|
$this->knownNames = array_pop($this->knownNameStack);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) {
|
NodeKind::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) {
|
||||||
$fieldName = $node->name->value;
|
$fieldName = $node->name->value;
|
||||||
|
|
||||||
if (!empty($this->knownNames[$fieldName])) {
|
if (!empty($this->knownNames[$fieldName])) {
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
@ -22,7 +22,7 @@ class UniqueOperationNames
|
|||||||
$this->knownOperationNames = [];
|
$this->knownOperationNames = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) {
|
NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) {
|
||||||
$operationName = $node->name;
|
$operationName = $node->name;
|
||||||
|
|
||||||
if ($operationName) {
|
if ($operationName) {
|
||||||
@ -37,7 +37,7 @@ class UniqueOperationNames
|
|||||||
}
|
}
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeType::FRAGMENT_DEFINITION => function() {
|
NodeKind::FRAGMENT_DEFINITION => function() {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
@ -21,10 +21,10 @@ class UniqueVariableNames
|
|||||||
$this->knownVariableNames = [];
|
$this->knownVariableNames = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => function() {
|
NodeKind::OPERATION_DEFINITION => function() {
|
||||||
$this->knownVariableNames = [];
|
$this->knownVariableNames = [];
|
||||||
},
|
},
|
||||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
|
NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
|
||||||
$variableName = $node->variable->name->value;
|
$variableName = $node->variable->name->value;
|
||||||
if (!empty($this->knownVariableNames[$variableName])) {
|
if (!empty($this->knownVariableNames[$variableName])) {
|
||||||
$context->reportError(new Error(
|
$context->reportError(new Error(
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Type\Definition\InputType;
|
use GraphQL\Type\Definition\InputType;
|
||||||
@ -22,7 +22,7 @@ class VariablesAreInputTypes
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
|
NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
|
||||||
$type = Utils\TypeInfo::typeFromAST($context->getSchema(), $node->type);
|
$type = Utils\TypeInfo::typeFromAST($context->getSchema(), $node->type);
|
||||||
|
|
||||||
// If the variable type is not an input type, return an error.
|
// If the variable type is not an input type, return an error.
|
||||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
use GraphQL\Language\AST\VariableNode;
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
@ -29,7 +29,7 @@ class VariablesInAllowedPosition
|
|||||||
public function __invoke(ValidationContext $context)
|
public function __invoke(ValidationContext $context)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'enter' => function () {
|
'enter' => function () {
|
||||||
$this->varDefMap = [];
|
$this->varDefMap = [];
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ class VariablesInAllowedPosition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
NodeType::VARIABLE_DEFINITION => function (VariableDefinitionNode $varDefNode) {
|
NodeKind::VARIABLE_DEFINITION => function (VariableDefinitionNode $varDefNode) {
|
||||||
$this->varDefMap[$varDefNode->variable->name->value] = $varDefNode;
|
$this->varDefMap[$varDefNode->variable->name->value] = $varDefNode;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator;
|
|||||||
|
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||||
use GraphQL\Language\AST\HasSelectionSet;
|
use GraphQL\Language\AST\HasSelectionSet;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
use GraphQL\Language\AST\VariableNode;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
@ -133,7 +133,7 @@ class ValidationContext
|
|||||||
if (!$fragments) {
|
if (!$fragments) {
|
||||||
$this->fragments = $fragments =
|
$this->fragments = $fragments =
|
||||||
array_reduce($this->getDocument()->definitions, function($frags, $statement) {
|
array_reduce($this->getDocument()->definitions, function($frags, $statement) {
|
||||||
if ($statement->kind === NodeType::FRAGMENT_DEFINITION) {
|
if ($statement->kind === NodeKind::FRAGMENT_DEFINITION) {
|
||||||
$frags[$statement->name->value] = $statement;
|
$frags[$statement->name->value] = $statement;
|
||||||
}
|
}
|
||||||
return $frags;
|
return $frags;
|
||||||
@ -157,7 +157,7 @@ class ValidationContext
|
|||||||
|
|
||||||
for ($i = 0; $i < count($set->selections); $i++) {
|
for ($i = 0; $i < count($set->selections); $i++) {
|
||||||
$selection = $set->selections[$i];
|
$selection = $set->selections[$i];
|
||||||
if ($selection->kind === NodeType::FRAGMENT_SPREAD) {
|
if ($selection->kind === NodeKind::FRAGMENT_SPREAD) {
|
||||||
$spreads[] = $selection;
|
$spreads[] = $selection;
|
||||||
} else if ($selection->selectionSet) {
|
} else if ($selection->selectionSet) {
|
||||||
$setsToVisit[] = $selection->selectionSet;
|
$setsToVisit[] = $selection->selectionSet;
|
||||||
@ -214,10 +214,10 @@ class ValidationContext
|
|||||||
$newUsages = [];
|
$newUsages = [];
|
||||||
$typeInfo = new TypeInfo($this->schema);
|
$typeInfo = new TypeInfo($this->schema);
|
||||||
Visitor::visit($node, Visitor::visitWithTypeInfo($typeInfo, [
|
Visitor::visit($node, Visitor::visitWithTypeInfo($typeInfo, [
|
||||||
NodeType::VARIABLE_DEFINITION => function () {
|
NodeKind::VARIABLE_DEFINITION => function () {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
NodeType::VARIABLE => function (VariableNode $variable) use (&$newUsages, $typeInfo) {
|
NodeKind::VARIABLE => function (VariableNode $variable) use (&$newUsages, $typeInfo) {
|
||||||
$newUsages[] = ['node' => $variable, 'type' => $typeInfo->getInputType()];
|
$newUsages[] = ['node' => $variable, 'type' => $typeInfo->getInputType()];
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
@ -5,7 +5,7 @@ use GraphQL\Language\AST\ArgumentNode;
|
|||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\NameNode;
|
use GraphQL\Language\AST\NameNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\NullValueNode;
|
use GraphQL\Language\AST\NullValueNode;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Language\AST\StringValueNode;
|
use GraphQL\Language\AST\StringValueNode;
|
||||||
@ -259,39 +259,39 @@ fragment $fragmentName on Type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'loc' => $loc(0, 41),
|
'loc' => $loc(0, 41),
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OPERATION_DEFINITION,
|
'kind' => NodeKind::OPERATION_DEFINITION,
|
||||||
'loc' => $loc(0, 40),
|
'loc' => $loc(0, 40),
|
||||||
'operation' => 'query',
|
'operation' => 'query',
|
||||||
'name' => null,
|
'name' => null,
|
||||||
'variableDefinitions' => null,
|
'variableDefinitions' => null,
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'selectionSet' => [
|
'selectionSet' => [
|
||||||
'kind' => NodeType::SELECTION_SET,
|
'kind' => NodeKind::SELECTION_SET,
|
||||||
'loc' => $loc(0, 40),
|
'loc' => $loc(0, 40),
|
||||||
'selections' => [
|
'selections' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::FIELD,
|
'kind' => NodeKind::FIELD,
|
||||||
'loc' => $loc(4, 38),
|
'loc' => $loc(4, 38),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => $loc(4, 8),
|
'loc' => $loc(4, 8),
|
||||||
'value' => 'node'
|
'value' => 'node'
|
||||||
],
|
],
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::ARGUMENT,
|
'kind' => NodeKind::ARGUMENT,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => $loc(9, 11),
|
'loc' => $loc(9, 11),
|
||||||
'value' => 'id'
|
'value' => 'id'
|
||||||
],
|
],
|
||||||
'value' => [
|
'value' => [
|
||||||
'kind' => NodeType::INT,
|
'kind' => NodeKind::INT,
|
||||||
'loc' => $loc(13, 14),
|
'loc' => $loc(13, 14),
|
||||||
'value' => '4'
|
'value' => '4'
|
||||||
],
|
],
|
||||||
@ -300,15 +300,15 @@ fragment $fragmentName on Type {
|
|||||||
],
|
],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'selectionSet' => [
|
'selectionSet' => [
|
||||||
'kind' => NodeType::SELECTION_SET,
|
'kind' => NodeKind::SELECTION_SET,
|
||||||
'loc' => $loc(16, 38),
|
'loc' => $loc(16, 38),
|
||||||
'selections' => [
|
'selections' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::FIELD,
|
'kind' => NodeKind::FIELD,
|
||||||
'loc' => $loc(22, 24),
|
'loc' => $loc(22, 24),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => $loc(22, 24),
|
'loc' => $loc(22, 24),
|
||||||
'value' => 'id'
|
'value' => 'id'
|
||||||
],
|
],
|
||||||
@ -317,11 +317,11 @@ fragment $fragmentName on Type {
|
|||||||
'selectionSet' => null
|
'selectionSet' => null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'kind' => NodeType::FIELD,
|
'kind' => NodeKind::FIELD,
|
||||||
'loc' => $loc(30, 34),
|
'loc' => $loc(30, 34),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => $loc(30, 34),
|
'loc' => $loc(30, 34),
|
||||||
'value' => 'name'
|
'value' => 'name'
|
||||||
],
|
],
|
||||||
@ -391,7 +391,7 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesNullValues()
|
public function testParsesNullValues()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::NULL,
|
'kind' => NodeKind::NULL,
|
||||||
'loc' => ['start' => 0, 'end' => 4]
|
'loc' => ['start' => 0, 'end' => 4]
|
||||||
], $this->nodeToArray(Parser::parseValue('null')));
|
], $this->nodeToArray(Parser::parseValue('null')));
|
||||||
}
|
}
|
||||||
@ -402,16 +402,16 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesListValues()
|
public function testParsesListValues()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::LST,
|
'kind' => NodeKind::LST,
|
||||||
'loc' => ['start' => 0, 'end' => 11],
|
'loc' => ['start' => 0, 'end' => 11],
|
||||||
'values' => [
|
'values' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::INT,
|
'kind' => NodeKind::INT,
|
||||||
'loc' => ['start' => 1, 'end' => 4],
|
'loc' => ['start' => 1, 'end' => 4],
|
||||||
'value' => '123'
|
'value' => '123'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'kind' => NodeType::STRING,
|
'kind' => NodeKind::STRING,
|
||||||
'loc' => ['start' => 5, 'end' => 10],
|
'loc' => ['start' => 5, 'end' => 10],
|
||||||
'value' => 'abc'
|
'value' => 'abc'
|
||||||
]
|
]
|
||||||
@ -427,10 +427,10 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesWellKnownTypes()
|
public function testParsesWellKnownTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'String'
|
'value' => 'String'
|
||||||
]
|
]
|
||||||
@ -443,10 +443,10 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesCustomTypes()
|
public function testParsesCustomTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -459,13 +459,13 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesListTypes()
|
public function testParsesListTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::LIST_TYPE,
|
'kind' => NodeKind::LIST_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 8],
|
'loc' => ['start' => 0, 'end' => 8],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -479,13 +479,13 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesNonNullTypes()
|
public function testParsesNonNullTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::NON_NULL_TYPE,
|
'kind' => NodeKind::NON_NULL_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 7],
|
'loc' => ['start' => 0, 'end' => 7],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -499,16 +499,16 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesNestedTypes()
|
public function testParsesNestedTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => NodeType::LIST_TYPE,
|
'kind' => NodeKind::LIST_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 9],
|
'loc' => ['start' => 0, 'end' => 9],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => NodeType::NON_NULL_TYPE,
|
'kind' => NodeKind::NON_NULL_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 8],
|
'loc' => ['start' => 1, 'end' => 8],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
|
@ -14,7 +14,7 @@ use GraphQL\Language\AST\Location;
|
|||||||
use GraphQL\Language\AST\NameNode;
|
use GraphQL\Language\AST\NameNode;
|
||||||
use GraphQL\Language\AST\NamedTypeNode;
|
use GraphQL\Language\AST\NamedTypeNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\NonNullTypeNode;
|
use GraphQL\Language\AST\NonNullTypeNode;
|
||||||
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
|
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
|
||||||
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
||||||
@ -40,10 +40,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -77,12 +77,12 @@ extend type Hello {
|
|||||||
return TestUtils::locArray($start, $end);
|
return TestUtils::locArray($start, $end);
|
||||||
};
|
};
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::TYPE_EXTENSION_DEFINITION,
|
'kind' => NodeKind::TYPE_EXTENSION_DEFINITION,
|
||||||
'definition' => [
|
'definition' => [
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(13, 18)),
|
'name' => $this->nameNode('Hello', $loc(13, 18)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -118,10 +118,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6,11)),
|
'name' => $this->nameNode('Hello', $loc(6,11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -129,7 +129,7 @@ type Hello {
|
|||||||
$this->fieldNode(
|
$this->fieldNode(
|
||||||
$this->nameNode('world', $loc(16, 21)),
|
$this->nameNode('world', $loc(16, 21)),
|
||||||
[
|
[
|
||||||
'kind' => NodeType::NON_NULL_TYPE,
|
'kind' => NodeKind::NON_NULL_TYPE,
|
||||||
'type' => $this->typeNode('String', $loc(23, 29)),
|
'type' => $this->typeNode('String', $loc(23, 29)),
|
||||||
'loc' => $loc(23, 30)
|
'loc' => $loc(23, 30)
|
||||||
],
|
],
|
||||||
@ -155,10 +155,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
||||||
'interfaces' => [
|
'interfaces' => [
|
||||||
$this->typeNode('World', $loc(22, 27))
|
$this->typeNode('World', $loc(22, 27))
|
||||||
@ -184,10 +184,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
||||||
'interfaces' => [
|
'interfaces' => [
|
||||||
$this->typeNode('Wo', $loc(22,24)),
|
$this->typeNode('Wo', $loc(22,24)),
|
||||||
@ -214,10 +214,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::ENUM_TYPE_DEFINITION,
|
'kind' => NodeKind::ENUM_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'values' => [$this->enumValueNode('WORLD', $loc(13, 18))],
|
'values' => [$this->enumValueNode('WORLD', $loc(13, 18))],
|
||||||
@ -240,10 +240,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::ENUM_TYPE_DEFINITION,
|
'kind' => NodeKind::ENUM_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'values' => [
|
'values' => [
|
||||||
@ -272,10 +272,10 @@ interface Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::INTERFACE_TYPE_DEFINITION,
|
'kind' => NodeKind::INTERFACE_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(11, 16)),
|
'name' => $this->nameNode('Hello', $loc(11, 16)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -306,10 +306,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -350,10 +350,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -365,7 +365,7 @@ type Hello {
|
|||||||
$this->inputValueNode(
|
$this->inputValueNode(
|
||||||
$this->nameNode('flag', $loc(22, 26)),
|
$this->nameNode('flag', $loc(22, 26)),
|
||||||
$this->typeNode('Boolean', $loc(28, 35)),
|
$this->typeNode('Boolean', $loc(28, 35)),
|
||||||
['kind' => NodeType::BOOLEAN, 'value' => true, 'loc' => $loc(38, 42)],
|
['kind' => NodeKind::BOOLEAN, 'value' => true, 'loc' => $loc(38, 42)],
|
||||||
$loc(22, 42)
|
$loc(22, 42)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -393,10 +393,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -407,7 +407,7 @@ type Hello {
|
|||||||
[
|
[
|
||||||
$this->inputValueNode(
|
$this->inputValueNode(
|
||||||
$this->nameNode('things', $loc(22,28)),
|
$this->nameNode('things', $loc(22,28)),
|
||||||
['kind' => NodeType::LIST_TYPE, 'type' => $this->typeNode('String', $loc(31, 37)), 'loc' => $loc(30, 38)],
|
['kind' => NodeKind::LIST_TYPE, 'type' => $this->typeNode('String', $loc(31, 37)), 'loc' => $loc(30, 38)],
|
||||||
null,
|
null,
|
||||||
$loc(22, 38)
|
$loc(22, 38)
|
||||||
)
|
)
|
||||||
@ -437,10 +437,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -483,10 +483,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::UNION_TYPE_DEFINITION,
|
'kind' => NodeKind::UNION_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'types' => [$this->typeNode('World', $loc(14, 19))],
|
'types' => [$this->typeNode('World', $loc(14, 19))],
|
||||||
@ -509,10 +509,10 @@ type Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::UNION_TYPE_DEFINITION,
|
'kind' => NodeKind::UNION_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'types' => [
|
'types' => [
|
||||||
@ -536,10 +536,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::SCALAR_TYPE_DEFINITION,
|
'kind' => NodeKind::SCALAR_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'loc' => $loc(0, 12)
|
'loc' => $loc(0, 12)
|
||||||
@ -563,10 +563,10 @@ input Hello {
|
|||||||
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => NodeType::DOCUMENT,
|
'kind' => NodeKind::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => NodeType::INPUT_OBJECT_TYPE_DEFINITION,
|
'kind' => NodeKind::INPUT_OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -601,8 +601,8 @@ input Hello {
|
|||||||
private function typeNode($name, $loc)
|
private function typeNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => NodeType::NAMED_TYPE,
|
'kind' => NodeKind::NAMED_TYPE,
|
||||||
'name' => ['kind' => NodeType::NAME, 'value' => $name, 'loc' => $loc],
|
'name' => ['kind' => NodeKind::NAME, 'value' => $name, 'loc' => $loc],
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ input Hello {
|
|||||||
private function nameNode($name, $loc)
|
private function nameNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => NodeType::NAME,
|
'kind' => NodeKind::NAME,
|
||||||
'value' => $name,
|
'value' => $name,
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
];
|
];
|
||||||
@ -624,7 +624,7 @@ input Hello {
|
|||||||
private function fieldNodeWithArgs($name, $type, $args, $loc)
|
private function fieldNodeWithArgs($name, $type, $args, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => NodeType::FIELD_DEFINITION,
|
'kind' => NodeKind::FIELD_DEFINITION,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'arguments' => $args,
|
'arguments' => $args,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
@ -636,7 +636,7 @@ input Hello {
|
|||||||
private function enumValueNode($name, $loc)
|
private function enumValueNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => NodeType::ENUM_VALUE_DEFINITION,
|
'kind' => NodeKind::ENUM_VALUE_DEFINITION,
|
||||||
'name' => $this->nameNode($name, $loc),
|
'name' => $this->nameNode($name, $loc),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
@ -646,7 +646,7 @@ input Hello {
|
|||||||
private function inputValueNode($name, $type, $defaultValue, $loc)
|
private function inputValueNode($name, $type, $defaultValue, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => NodeType::INPUT_VALUE_DEFINITION,
|
'kind' => NodeKind::INPUT_VALUE_DEFINITION,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'defaultValue' => $defaultValue,
|
'defaultValue' => $defaultValue,
|
||||||
|
@ -5,7 +5,7 @@ use GraphQL\Language\AST\DocumentNode;
|
|||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\NameNode;
|
use GraphQL\Language\AST\NameNode;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeType;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\SelectionSetNode;
|
use GraphQL\Language\AST\SelectionSetNode;
|
||||||
use GraphQL\Language\Parser;
|
use GraphQL\Language\Parser;
|
||||||
@ -26,7 +26,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$selectionSet = null;
|
$selectionSet = null;
|
||||||
$editedAst = Visitor::visit($ast, [
|
$editedAst = Visitor::visit($ast, [
|
||||||
NodeType::OPERATION_DEFINITION => [
|
NodeKind::OPERATION_DEFINITION => [
|
||||||
'enter' => function(OperationDefinitionNode $node) use (&$selectionSet) {
|
'enter' => function(OperationDefinitionNode $node) use (&$selectionSet) {
|
||||||
$selectionSet = $node->selectionSet;
|
$selectionSet = $node->selectionSet;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$definitions = $ast->definitions;
|
$definitions = $ast->definitions;
|
||||||
|
|
||||||
$editedAst = Visitor::visit($ast, [
|
$editedAst = Visitor::visit($ast, [
|
||||||
NodeType::DOCUMENT => [
|
NodeKind::DOCUMENT => [
|
||||||
'enter' => function (DocumentNode $node) {
|
'enter' => function (DocumentNode $node) {
|
||||||
$tmp = clone $node;
|
$tmp = clone $node;
|
||||||
$tmp->definitions = [];
|
$tmp->definitions = [];
|
||||||
@ -265,7 +265,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'leave' => function($node) use (&$visited) {
|
'leave' => function($node) use (&$visited) {
|
||||||
$visited[] = ['leave', $node->kind, isset($node->value) ? $node->value : null];
|
$visited[] = ['leave', $node->kind, isset($node->value) ? $node->value : null];
|
||||||
|
|
||||||
if ($node->kind === NodeType::NAME && $node->value === 'x') {
|
if ($node->kind === NodeKind::NAME && $node->value === 'x') {
|
||||||
return Visitor::stop();
|
return Visitor::stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,10 +298,10 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$ast = Parser::parse('{ a, b { x }, c }');
|
$ast = Parser::parse('{ a, b { x }, c }');
|
||||||
|
|
||||||
Visitor::visit($ast, [
|
Visitor::visit($ast, [
|
||||||
NodeType::NAME => function(NameNode $node) use (&$visited) {
|
NodeKind::NAME => function(NameNode $node) use (&$visited) {
|
||||||
$visited[] = ['enter', $node->kind, $node->value];
|
$visited[] = ['enter', $node->kind, $node->value];
|
||||||
},
|
},
|
||||||
NodeType::SELECTION_SET => [
|
NodeKind::SELECTION_SET => [
|
||||||
'enter' => function(SelectionSetNode $node) use (&$visited) {
|
'enter' => function(SelectionSetNode $node) use (&$visited) {
|
||||||
$visited[] = ['enter', $node->kind, null];
|
$visited[] = ['enter', $node->kind, null];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user