diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index a4472f8..4f58f4d 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -7,7 +7,7 @@ use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Schema; @@ -119,7 +119,7 @@ class Executor foreach ($documentNode->definitions as $definition) { switch ($definition->kind) { - case NodeType::OPERATION_DEFINITION: + case NodeKind::OPERATION_DEFINITION: if (!$operationName && $operation) { throw new Error( 'Must provide operation name if query contains multiple operations.' @@ -130,7 +130,7 @@ class Executor $operation = $definition; } break; - case NodeType::FRAGMENT_DEFINITION: + case NodeKind::FRAGMENT_DEFINITION: $fragments[$definition->name->value] = $definition; break; default: @@ -271,7 +271,7 @@ class Executor { foreach ($selectionSet->selections as $selection) { switch ($selection->kind) { - case NodeType::FIELD: + case NodeKind::FIELD: if (!self::shouldIncludeNode($exeContext, $selection->directives)) { continue; } @@ -281,7 +281,7 @@ class Executor } $fields[$name][] = $selection; break; - case NodeType::INLINE_FRAGMENT: + case NodeKind::INLINE_FRAGMENT: if (!self::shouldIncludeNode($exeContext, $selection->directives) || !self::doesFragmentConditionMatch($exeContext, $selection, $runtimeType) ) { @@ -295,7 +295,7 @@ class Executor $visitedFragmentNames ); break; - case NodeType::FRAGMENT_SPREAD: + case NodeKind::FRAGMENT_SPREAD: $fragName = $selection->name->value; if (!empty($visitedFragmentNames[$fragName]) || !self::shouldIncludeNode($exeContext, $selection->directives)) { continue; diff --git a/src/Language/AST/ArgumentNode.php b/src/Language/AST/ArgumentNode.php index 056db12..3c942e7 100644 --- a/src/Language/AST/ArgumentNode.php +++ b/src/Language/AST/ArgumentNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class ArgumentNode extends Node { - public $kind = NodeType::ARGUMENT; + public $kind = NodeKind::ARGUMENT; /** * @var ValueNode diff --git a/src/Language/AST/BooleanValueNode.php b/src/Language/AST/BooleanValueNode.php index b626a87..8f5f755 100644 --- a/src/Language/AST/BooleanValueNode.php +++ b/src/Language/AST/BooleanValueNode.php @@ -4,7 +4,7 @@ namespace GraphQL\Language\AST; class BooleanValueNode extends Node implements ValueNode { - public $kind = NodeType::BOOLEAN; + public $kind = NodeKind::BOOLEAN; /** * @var string diff --git a/src/Language/AST/DirectiveDefinitionNode.php b/src/Language/AST/DirectiveDefinitionNode.php index 70c1641..1e80084 100644 --- a/src/Language/AST/DirectiveDefinitionNode.php +++ b/src/Language/AST/DirectiveDefinitionNode.php @@ -6,7 +6,7 @@ class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode /** * @var string */ - public $kind = NodeType::DIRECTIVE_DEFINITION; + public $kind = NodeKind::DIRECTIVE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/DirectiveNode.php b/src/Language/AST/DirectiveNode.php index 4e1172f..e14aa3c 100644 --- a/src/Language/AST/DirectiveNode.php +++ b/src/Language/AST/DirectiveNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class DirectiveNode extends Node { - public $kind = NodeType::DIRECTIVE; + public $kind = NodeKind::DIRECTIVE; /** * @var NameNode diff --git a/src/Language/AST/DocumentNode.php b/src/Language/AST/DocumentNode.php index 502669f..131db20 100644 --- a/src/Language/AST/DocumentNode.php +++ b/src/Language/AST/DocumentNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class DocumentNode extends Node { - public $kind = NodeType::DOCUMENT; + public $kind = NodeKind::DOCUMENT; /** * @var DefinitionNode[] diff --git a/src/Language/AST/EnumTypeDefinitionNode.php b/src/Language/AST/EnumTypeDefinitionNode.php index b6a3ae2..2ceb6a4 100644 --- a/src/Language/AST/EnumTypeDefinitionNode.php +++ b/src/Language/AST/EnumTypeDefinitionNode.php @@ -6,7 +6,7 @@ class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::ENUM_TYPE_DEFINITION; + public $kind = NodeKind::ENUM_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/EnumValueDefinitionNode.php b/src/Language/AST/EnumValueDefinitionNode.php index fd570a2..6cd2c14 100644 --- a/src/Language/AST/EnumValueDefinitionNode.php +++ b/src/Language/AST/EnumValueDefinitionNode.php @@ -6,7 +6,7 @@ class EnumValueDefinitionNode extends Node /** * @var string */ - public $kind = NodeType::ENUM_VALUE_DEFINITION; + public $kind = NodeKind::ENUM_VALUE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/EnumValueNode.php b/src/Language/AST/EnumValueNode.php index deac38a..82c3991 100644 --- a/src/Language/AST/EnumValueNode.php +++ b/src/Language/AST/EnumValueNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class EnumValueNode extends Node implements ValueNode { - public $kind = NodeType::ENUM; + public $kind = NodeKind::ENUM; /** * @var string diff --git a/src/Language/AST/FieldDefinitionNode.php b/src/Language/AST/FieldDefinitionNode.php index 97ccb21..b271e78 100644 --- a/src/Language/AST/FieldDefinitionNode.php +++ b/src/Language/AST/FieldDefinitionNode.php @@ -6,7 +6,7 @@ class FieldDefinitionNode extends Node /** * @var string */ - public $kind = NodeType::FIELD_DEFINITION; + public $kind = NodeKind::FIELD_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/FieldNode.php b/src/Language/AST/FieldNode.php index caf7cd4..b9a9b8b 100644 --- a/src/Language/AST/FieldNode.php +++ b/src/Language/AST/FieldNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class FieldNode extends Node implements SelectionNode { - public $kind = NodeType::FIELD; + public $kind = NodeKind::FIELD; /** * @var NameNode diff --git a/src/Language/AST/FloatValueNode.php b/src/Language/AST/FloatValueNode.php index 02c388c..c4090a6 100644 --- a/src/Language/AST/FloatValueNode.php +++ b/src/Language/AST/FloatValueNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class FloatValueNode extends Node implements ValueNode { - public $kind = NodeType::FLOAT; + public $kind = NodeKind::FLOAT; /** * @var string diff --git a/src/Language/AST/FragmentDefinitionNode.php b/src/Language/AST/FragmentDefinitionNode.php index f3a02a2..306cac6 100644 --- a/src/Language/AST/FragmentDefinitionNode.php +++ b/src/Language/AST/FragmentDefinitionNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet { - public $kind = NodeType::FRAGMENT_DEFINITION; + public $kind = NodeKind::FRAGMENT_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/FragmentSpreadNode.php b/src/Language/AST/FragmentSpreadNode.php index 44b9d76..2c8eab7 100644 --- a/src/Language/AST/FragmentSpreadNode.php +++ b/src/Language/AST/FragmentSpreadNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class FragmentSpreadNode extends Node implements SelectionNode { - public $kind = NodeType::FRAGMENT_SPREAD; + public $kind = NodeKind::FRAGMENT_SPREAD; /** * @var NameNode diff --git a/src/Language/AST/InlineFragmentNode.php b/src/Language/AST/InlineFragmentNode.php index d21aef3..2c5d473 100644 --- a/src/Language/AST/InlineFragmentNode.php +++ b/src/Language/AST/InlineFragmentNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class InlineFragmentNode extends Node implements SelectionNode { - public $kind = NodeType::INLINE_FRAGMENT; + public $kind = NodeKind::INLINE_FRAGMENT; /** * @var NamedTypeNode diff --git a/src/Language/AST/InputObjectTypeDefinitionNode.php b/src/Language/AST/InputObjectTypeDefinitionNode.php index 0c39079..19df4f2 100644 --- a/src/Language/AST/InputObjectTypeDefinitionNode.php +++ b/src/Language/AST/InputObjectTypeDefinitionNode.php @@ -6,7 +6,7 @@ class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION; + public $kind = NodeKind::INPUT_OBJECT_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/InputValueDefinitionNode.php b/src/Language/AST/InputValueDefinitionNode.php index d9db0a6..5786d58 100644 --- a/src/Language/AST/InputValueDefinitionNode.php +++ b/src/Language/AST/InputValueDefinitionNode.php @@ -6,7 +6,7 @@ class InputValueDefinitionNode extends Node /** * @var string */ - public $kind = NodeType::INPUT_VALUE_DEFINITION; + public $kind = NodeKind::INPUT_VALUE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/IntValueNode.php b/src/Language/AST/IntValueNode.php index 5a130f2..e45e5a1 100644 --- a/src/Language/AST/IntValueNode.php +++ b/src/Language/AST/IntValueNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class IntValueNode extends Node implements ValueNode { - public $kind = NodeType::INT; + public $kind = NodeKind::INT; /** * @var string diff --git a/src/Language/AST/InterfaceTypeDefinitionNode.php b/src/Language/AST/InterfaceTypeDefinitionNode.php index 0288017..e16f222 100644 --- a/src/Language/AST/InterfaceTypeDefinitionNode.php +++ b/src/Language/AST/InterfaceTypeDefinitionNode.php @@ -6,7 +6,7 @@ class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::INTERFACE_TYPE_DEFINITION; + public $kind = NodeKind::INTERFACE_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/ListTypeNode.php b/src/Language/AST/ListTypeNode.php index 398af61..4493cff 100644 --- a/src/Language/AST/ListTypeNode.php +++ b/src/Language/AST/ListTypeNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class ListTypeNode extends Node implements TypeNode { - public $kind = NodeType::LIST_TYPE; + public $kind = NodeKind::LIST_TYPE; /** * @var Node diff --git a/src/Language/AST/ListValueNode.php b/src/Language/AST/ListValueNode.php index 0c9690f..1a43512 100644 --- a/src/Language/AST/ListValueNode.php +++ b/src/Language/AST/ListValueNode.php @@ -4,7 +4,7 @@ namespace GraphQL\Language\AST; class ListValueNode extends Node implements ValueNode { - public $kind = NodeType::LST; + public $kind = NodeKind::LST; /** * @var ValueNode[] diff --git a/src/Language/AST/NameNode.php b/src/Language/AST/NameNode.php index c2e5504..7860775 100644 --- a/src/Language/AST/NameNode.php +++ b/src/Language/AST/NameNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class NameNode extends Node implements TypeNode { - public $kind = NodeType::NAME; + public $kind = NodeKind::NAME; /** * @var string diff --git a/src/Language/AST/NamedTypeNode.php b/src/Language/AST/NamedTypeNode.php index dc66f12..e9496d2 100644 --- a/src/Language/AST/NamedTypeNode.php +++ b/src/Language/AST/NamedTypeNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class NamedTypeNode extends Node implements TypeNode { - public $kind = NodeType::NAMED_TYPE; + public $kind = NodeKind::NAMED_TYPE; /** * @var NameNode diff --git a/src/Language/AST/NodeType.php b/src/Language/AST/NodeKind.php similarity index 99% rename from src/Language/AST/NodeType.php rename to src/Language/AST/NodeKind.php index 42886a7..f3fc465 100644 --- a/src/Language/AST/NodeType.php +++ b/src/Language/AST/NodeKind.php @@ -2,7 +2,7 @@ namespace GraphQL\Language\AST; -class NodeType +class NodeKind { // constants from language/kinds.js: diff --git a/src/Language/AST/NonNullTypeNode.php b/src/Language/AST/NonNullTypeNode.php index efb083c..e450404 100644 --- a/src/Language/AST/NonNullTypeNode.php +++ b/src/Language/AST/NonNullTypeNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class NonNullTypeNode extends Node implements TypeNode { - public $kind = NodeType::NON_NULL_TYPE; + public $kind = NodeKind::NON_NULL_TYPE; /** * @var NameNode | ListTypeNode diff --git a/src/Language/AST/NullValueNode.php b/src/Language/AST/NullValueNode.php index 0af487a..54a36b2 100644 --- a/src/Language/AST/NullValueNode.php +++ b/src/Language/AST/NullValueNode.php @@ -3,5 +3,5 @@ namespace GraphQL\Language\AST; class NullValueNode extends Node implements ValueNode { - public $kind = NodeType::NULL; + public $kind = NodeKind::NULL; } diff --git a/src/Language/AST/ObjectFieldNode.php b/src/Language/AST/ObjectFieldNode.php index f268382..fa55fc7 100644 --- a/src/Language/AST/ObjectFieldNode.php +++ b/src/Language/AST/ObjectFieldNode.php @@ -4,7 +4,7 @@ namespace GraphQL\Language\AST; class ObjectFieldNode extends Node { - public $kind = NodeType::OBJECT_FIELD; + public $kind = NodeKind::OBJECT_FIELD; /** * @var NameNode diff --git a/src/Language/AST/ObjectTypeDefinitionNode.php b/src/Language/AST/ObjectTypeDefinitionNode.php index b1ff004..e39f8bb 100644 --- a/src/Language/AST/ObjectTypeDefinitionNode.php +++ b/src/Language/AST/ObjectTypeDefinitionNode.php @@ -6,7 +6,7 @@ class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::OBJECT_TYPE_DEFINITION; + public $kind = NodeKind::OBJECT_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/ObjectValueNode.php b/src/Language/AST/ObjectValueNode.php index e91f8cc..2dd38ca 100644 --- a/src/Language/AST/ObjectValueNode.php +++ b/src/Language/AST/ObjectValueNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class ObjectValueNode extends Node implements ValueNode { - public $kind = NodeType::OBJECT; + public $kind = NodeKind::OBJECT; /** * @var ObjectFieldNode[] diff --git a/src/Language/AST/OperationDefinitionNode.php b/src/Language/AST/OperationDefinitionNode.php index 01383d3..0fb6e7b 100644 --- a/src/Language/AST/OperationDefinitionNode.php +++ b/src/Language/AST/OperationDefinitionNode.php @@ -6,7 +6,7 @@ class OperationDefinitionNode extends Node implements DefinitionNode, HasSelecti /** * @var string */ - public $kind = NodeType::OPERATION_DEFINITION; + public $kind = NodeKind::OPERATION_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/OperationTypeDefinitionNode.php b/src/Language/AST/OperationTypeDefinitionNode.php index 5daf636..445d39a 100644 --- a/src/Language/AST/OperationTypeDefinitionNode.php +++ b/src/Language/AST/OperationTypeDefinitionNode.php @@ -6,7 +6,7 @@ class OperationTypeDefinitionNode extends Node /** * @var string */ - public $kind = NodeType::OPERATION_TYPE_DEFINITION; + public $kind = NodeKind::OPERATION_TYPE_DEFINITION; /** * One of 'query' | 'mutation' | 'subscription' diff --git a/src/Language/AST/ScalarTypeDefinitionNode.php b/src/Language/AST/ScalarTypeDefinitionNode.php index e184b43..1609911 100644 --- a/src/Language/AST/ScalarTypeDefinitionNode.php +++ b/src/Language/AST/ScalarTypeDefinitionNode.php @@ -6,7 +6,7 @@ class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::SCALAR_TYPE_DEFINITION; + public $kind = NodeKind::SCALAR_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/SchemaDefinitionNode.php b/src/Language/AST/SchemaDefinitionNode.php index a82915f..e2f0072 100644 --- a/src/Language/AST/SchemaDefinitionNode.php +++ b/src/Language/AST/SchemaDefinitionNode.php @@ -6,7 +6,7 @@ class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode /** * @var string */ - public $kind = NodeType::SCHEMA_DEFINITION; + public $kind = NodeKind::SCHEMA_DEFINITION; /** * @var DirectiveNode[] diff --git a/src/Language/AST/SelectionSetNode.php b/src/Language/AST/SelectionSetNode.php index f90d90d..12895b5 100644 --- a/src/Language/AST/SelectionSetNode.php +++ b/src/Language/AST/SelectionSetNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class SelectionSetNode extends Node { - public $kind = NodeType::SELECTION_SET; + public $kind = NodeKind::SELECTION_SET; /** * @var SelectionNode[] diff --git a/src/Language/AST/StringValueNode.php b/src/Language/AST/StringValueNode.php index 77da32c..d729b5a 100644 --- a/src/Language/AST/StringValueNode.php +++ b/src/Language/AST/StringValueNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class StringValueNode extends Node implements ValueNode { - public $kind = NodeType::STRING; + public $kind = NodeKind::STRING; /** * @var string diff --git a/src/Language/AST/TypeExtensionDefinitionNode.php b/src/Language/AST/TypeExtensionDefinitionNode.php index 9f2e684..ca73157 100644 --- a/src/Language/AST/TypeExtensionDefinitionNode.php +++ b/src/Language/AST/TypeExtensionDefinitionNode.php @@ -6,7 +6,7 @@ class TypeExtensionDefinitionNode extends Node implements TypeSystemDefinitionNo /** * @var string */ - public $kind = NodeType::TYPE_EXTENSION_DEFINITION; + public $kind = NodeKind::TYPE_EXTENSION_DEFINITION; /** * @var ObjectTypeDefinitionNode diff --git a/src/Language/AST/UnionTypeDefinitionNode.php b/src/Language/AST/UnionTypeDefinitionNode.php index d61d87b..052bb7d 100644 --- a/src/Language/AST/UnionTypeDefinitionNode.php +++ b/src/Language/AST/UnionTypeDefinitionNode.php @@ -6,7 +6,7 @@ class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode /** * @var string */ - public $kind = NodeType::UNION_TYPE_DEFINITION; + public $kind = NodeKind::UNION_TYPE_DEFINITION; /** * @var NameNode diff --git a/src/Language/AST/VariableDefinitionNode.php b/src/Language/AST/VariableDefinitionNode.php index 641c91c..b3438f5 100644 --- a/src/Language/AST/VariableDefinitionNode.php +++ b/src/Language/AST/VariableDefinitionNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class VariableDefinitionNode extends Node implements DefinitionNode { - public $kind = NodeType::VARIABLE_DEFINITION; + public $kind = NodeKind::VARIABLE_DEFINITION; /** * @var VariableNode diff --git a/src/Language/AST/VariableNode.php b/src/Language/AST/VariableNode.php index e659781..feee896 100644 --- a/src/Language/AST/VariableNode.php +++ b/src/Language/AST/VariableNode.php @@ -3,7 +3,7 @@ namespace GraphQL\Language\AST; class VariableNode extends Node { - public $kind = NodeType::VARIABLE; + public $kind = NodeKind::VARIABLE; /** * @var NameNode diff --git a/src/Language/Printer.php b/src/Language/Printer.php index 4267ef0..9553273 100644 --- a/src/Language/Printer.php +++ b/src/Language/Printer.php @@ -23,7 +23,7 @@ use GraphQL\Language\AST\IntValueNode; use GraphQL\Language\AST\ListTypeNode; use GraphQL\Language\AST\NamedTypeNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NonNullTypeNode; use GraphQL\Language\AST\NullValueNode; use GraphQL\Language\AST\ObjectFieldNode; @@ -55,16 +55,16 @@ class Printer { return Visitor::visit($ast, [ 'leave' => [ - NodeType::NAME => function(Node $node) { + NodeKind::NAME => function(Node $node) { return '' . $node->value; }, - NodeType::VARIABLE => function($node) { + NodeKind::VARIABLE => function($node) { return '$' . $node->name; }, - NodeType::DOCUMENT => function(DocumentNode $node) { + NodeKind::DOCUMENT => function(DocumentNode $node) { return $this->join($node->definitions, "\n\n") . "\n"; }, - NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) { + NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) { $op = $node->operation; $name = $node->name; $varDefs = $this->wrap('(', $this->join($node->variableDefinitions, ', '), ')'); @@ -76,28 +76,28 @@ class Printer ? $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); }, - NodeType::SELECTION_SET => function(SelectionSetNode $node) { + NodeKind::SELECTION_SET => function(SelectionSetNode $node) { return $this->block($node->selections); }, - NodeType::FIELD => function(FieldNode $node) { + NodeKind::FIELD => function(FieldNode $node) { return $this->join([ $this->wrap('', $node->alias, ': ') . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'), $this->join($node->directives, ' '), $node->selectionSet ], ' '); }, - NodeType::ARGUMENT => function(ArgumentNode $node) { + NodeKind::ARGUMENT => function(ArgumentNode $node) { return $node->name . ': ' . $node->value; }, // Fragments - NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) { + NodeKind::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) { return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' ')); }, - NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) { + NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) { return $this->join([ "...", $this->wrap('on ', $node->typeCondition), @@ -105,73 +105,73 @@ class Printer $node->selectionSet ], ' '); }, - NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) { + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) { return "fragment {$node->name} on {$node->typeCondition} " . $this->wrap('', $this->join($node->directives, ' '), ' ') . $node->selectionSet; }, // Value - NodeType::INT => function(IntValueNode $node) { + NodeKind::INT => function(IntValueNode $node) { return $node->value; }, - NodeType::FLOAT => function(FloatValueNode $node) { + NodeKind::FLOAT => function(FloatValueNode $node) { return $node->value; }, - NodeType::STRING => function(StringValueNode $node) { + NodeKind::STRING => function(StringValueNode $node) { return json_encode($node->value); }, - NodeType::BOOLEAN => function(BooleanValueNode $node) { + NodeKind::BOOLEAN => function(BooleanValueNode $node) { return $node->value ? 'true' : 'false'; }, - NodeType::NULL => function(NullValueNode $node) { + NodeKind::NULL => function(NullValueNode $node) { return 'null'; }, - NodeType::ENUM => function(EnumValueNode $node) { + NodeKind::ENUM => function(EnumValueNode $node) { return $node->value; }, - NodeType::LST => function(ListValueNode $node) { + NodeKind::LST => function(ListValueNode $node) { return '[' . $this->join($node->values, ', ') . ']'; }, - NodeType::OBJECT => function(ObjectValueNode $node) { + NodeKind::OBJECT => function(ObjectValueNode $node) { return '{' . $this->join($node->fields, ', ') . '}'; }, - NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) { + NodeKind::OBJECT_FIELD => function(ObjectFieldNode $node) { return $node->name . ': ' . $node->value; }, // DirectiveNode - NodeType::DIRECTIVE => function(DirectiveNode $node) { + NodeKind::DIRECTIVE => function(DirectiveNode $node) { return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')'); }, // Type - NodeType::NAMED_TYPE => function(NamedTypeNode $node) { + NodeKind::NAMED_TYPE => function(NamedTypeNode $node) { return $node->name; }, - NodeType::LIST_TYPE => function(ListTypeNode $node) { + NodeKind::LIST_TYPE => function(ListTypeNode $node) { return '[' . $node->type . ']'; }, - NodeType::NON_NULL_TYPE => function(NonNullTypeNode $node) { + NodeKind::NON_NULL_TYPE => function(NonNullTypeNode $node) { return $node->type . '!'; }, // Type System Definitions - NodeType::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) { + NodeKind::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) { return $this->join([ 'schema', $this->join($def->directives, ' '), $this->block($def->operationTypes) ], ' '); }, - NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) { + NodeKind::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) { 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, ' ')], ' '); }, - NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinitionNode $def) { + NodeKind::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinitionNode $def) { return $this->join([ 'type', $def->name, @@ -180,20 +180,20 @@ class Printer $this->block($def->fields) ], ' '); }, - NodeType::FIELD_DEFINITION => function(FieldDefinitionNode $def) { + NodeKind::FIELD_DEFINITION => function(FieldDefinitionNode $def) { return $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')') . ': ' . $def->type . $this->wrap(' ', $this->join($def->directives, ' ')); }, - NodeType::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) { + NodeKind::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) { return $this->join([ $def->name . ': ' . $def->type, $this->wrap('= ', $def->defaultValue), $this->join($def->directives, ' ') ], ' '); }, - NodeType::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinitionNode $def) { + NodeKind::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinitionNode $def) { return $this->join([ 'interface', $def->name, @@ -201,7 +201,7 @@ class Printer $this->block($def->fields) ], ' '); }, - NodeType::UNION_TYPE_DEFINITION => function(UnionTypeDefinitionNode $def) { + NodeKind::UNION_TYPE_DEFINITION => function(UnionTypeDefinitionNode $def) { return $this->join([ 'union', $def->name, @@ -209,7 +209,7 @@ class Printer '= ' . $this->join($def->types, ' | ') ], ' '); }, - NodeType::ENUM_TYPE_DEFINITION => function(EnumTypeDefinitionNode $def) { + NodeKind::ENUM_TYPE_DEFINITION => function(EnumTypeDefinitionNode $def) { return $this->join([ 'enum', $def->name, @@ -217,13 +217,13 @@ class Printer $this->block($def->values) ], ' '); }, - NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) { + NodeKind::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) { return $this->join([ $def->name, $this->join($def->directives, ' ') ], ' '); }, - NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinitionNode $def) { + NodeKind::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinitionNode $def) { return $this->join([ 'input', $def->name, @@ -231,10 +231,10 @@ class Printer $this->block($def->fields) ], ' '); }, - NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) { + NodeKind::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) { 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, ', '), ')') . ' on ' . $this->join($def->locations, ' | '); } diff --git a/src/Language/Visitor.php b/src/Language/Visitor.php index 5a69c9d..56a0ad8 100644 --- a/src/Language/Visitor.php +++ b/src/Language/Visitor.php @@ -2,7 +2,7 @@ namespace GraphQL\Language; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Utils\TypeInfo; class VisitorOperation @@ -49,45 +49,45 @@ class Visitor } public static $visitorKeys = [ - NodeType::NAME => [], - NodeType::DOCUMENT => ['definitions'], - NodeType::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'], - NodeType::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'], - NodeType::VARIABLE => ['name'], - NodeType::SELECTION_SET => ['selections'], - NodeType::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'], - NodeType::ARGUMENT => ['name', 'value'], - NodeType::FRAGMENT_SPREAD => ['name', 'directives'], - NodeType::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'], - NodeType::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'], + NodeKind::NAME => [], + NodeKind::DOCUMENT => ['definitions'], + NodeKind::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'], + NodeKind::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'], + NodeKind::VARIABLE => ['name'], + NodeKind::SELECTION_SET => ['selections'], + NodeKind::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + NodeKind::ARGUMENT => ['name', 'value'], + NodeKind::FRAGMENT_SPREAD => ['name', 'directives'], + NodeKind::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'], + NodeKind::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'], - NodeType::INT => [], - NodeType::FLOAT => [], - NodeType::STRING => [], - NodeType::BOOLEAN => [], - NodeType::NULL => [], - NodeType::ENUM => [], - NodeType::LST => ['values'], - NodeType::OBJECT => ['fields'], - NodeType::OBJECT_FIELD => ['name', 'value'], - NodeType::DIRECTIVE => ['name', 'arguments'], - NodeType::NAMED_TYPE => ['name'], - NodeType::LIST_TYPE => ['type'], - NodeType::NON_NULL_TYPE => ['type'], + NodeKind::INT => [], + NodeKind::FLOAT => [], + NodeKind::STRING => [], + NodeKind::BOOLEAN => [], + NodeKind::NULL => [], + NodeKind::ENUM => [], + NodeKind::LST => ['values'], + NodeKind::OBJECT => ['fields'], + NodeKind::OBJECT_FIELD => ['name', 'value'], + NodeKind::DIRECTIVE => ['name', 'arguments'], + NodeKind::NAMED_TYPE => ['name'], + NodeKind::LIST_TYPE => ['type'], + NodeKind::NON_NULL_TYPE => ['type'], - NodeType::SCHEMA_DEFINITION => ['directives', 'operationTypes'], - NodeType::OPERATION_TYPE_DEFINITION => ['type'], - NodeType::SCALAR_TYPE_DEFINITION => ['name', 'directives'], - NodeType::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'], - NodeType::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'], - NodeType::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'], - NodeType::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ], - NodeType::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ], - NodeType::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ], - NodeType::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ], - NodeType::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ], - NodeType::TYPE_EXTENSION_DEFINITION => [ 'definition' ], - NodeType::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ] + NodeKind::SCHEMA_DEFINITION => ['directives', 'operationTypes'], + NodeKind::OPERATION_TYPE_DEFINITION => ['type'], + NodeKind::SCALAR_TYPE_DEFINITION => ['name', 'directives'], + NodeKind::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'], + NodeKind::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'], + NodeKind::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'], + NodeKind::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ], + NodeKind::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ], + NodeKind::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ], + NodeKind::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ], + NodeKind::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ], + NodeKind::TYPE_EXTENSION_DEFINITION => [ 'definition' ], + NodeKind::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ] ]; /** diff --git a/src/Utils/TypeInfo.php b/src/Utils/TypeInfo.php index c4eda75..e052c04 100644 --- a/src/Utils/TypeInfo.php +++ b/src/Utils/TypeInfo.php @@ -5,7 +5,7 @@ use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\ListTypeNode; use GraphQL\Language\AST\NamedTypeNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NonNullTypeNode; use GraphQL\Schema; use GraphQL\Type\Definition\AbstractType; @@ -310,7 +310,7 @@ class TypeInfo $schema = $this->schema; switch ($node->kind) { - case NodeType::SELECTION_SET: + case NodeKind::SELECTION_SET: $namedType = Type::getNamedType($this->getType()); $compositeType = null; if (Type::isCompositeType($namedType)) { @@ -320,7 +320,7 @@ class TypeInfo $this->parentTypeStack[] = $compositeType; // push break; - case NodeType::FIELD: + case NodeKind::FIELD: $parentType = $this->getParentType(); $fieldDef = null; if ($parentType) { @@ -330,11 +330,11 @@ class TypeInfo $this->typeStack[] = $fieldDef ? $fieldDef->getType() : null; // push break; - case NodeType::DIRECTIVE: + case NodeKind::DIRECTIVE: $this->directive = $schema->getDirective($node->name->value); break; - case NodeType::OPERATION_DEFINITION: + case NodeKind::OPERATION_DEFINITION: $type = null; if ($node->operation === 'query') { $type = $schema->getQueryType(); @@ -346,19 +346,19 @@ class TypeInfo $this->typeStack[] = $type; // push break; - case NodeType::INLINE_FRAGMENT: - case NodeType::FRAGMENT_DEFINITION: + case NodeKind::INLINE_FRAGMENT: + case NodeKind::FRAGMENT_DEFINITION: $typeConditionNode = $node->typeCondition; $outputType = $typeConditionNode ? self::typeFromAST($schema, $typeConditionNode) : $this->getType(); $this->typeStack[] = $outputType; // push break; - case NodeType::VARIABLE_DEFINITION: + case NodeKind::VARIABLE_DEFINITION: $inputType = self::typeFromAST($schema, $node->type); $this->inputTypeStack[] = $inputType; // push break; - case NodeType::ARGUMENT: + case NodeKind::ARGUMENT: $fieldOrDirective = $this->getDirective() ?: $this->getFieldDef(); $argDef = $argType = null; if ($fieldOrDirective) { @@ -371,12 +371,12 @@ class TypeInfo $this->inputTypeStack[] = $argType; // push break; - case NodeType::LST: + case NodeKind::LST: $listType = Type::getNullableType($this->getInputType()); $this->inputTypeStack[] = ($listType instanceof ListOfType ? $listType->getWrappedType() : null); // push break; - case NodeType::OBJECT_FIELD: + case NodeKind::OBJECT_FIELD: $objectType = Type::getNamedType($this->getInputType()); $fieldType = null; if ($objectType instanceof InputObjectType) { @@ -395,33 +395,33 @@ class TypeInfo function leave(Node $node) { switch ($node->kind) { - case NodeType::SELECTION_SET: + case NodeKind::SELECTION_SET: array_pop($this->parentTypeStack); break; - case NodeType::FIELD: + case NodeKind::FIELD: array_pop($this->fieldDefStack); array_pop($this->typeStack); break; - case NodeType::DIRECTIVE: + case NodeKind::DIRECTIVE: $this->directive = null; break; - case NodeType::OPERATION_DEFINITION: - case NodeType::INLINE_FRAGMENT: - case NodeType::FRAGMENT_DEFINITION: + case NodeKind::OPERATION_DEFINITION: + case NodeKind::INLINE_FRAGMENT: + case NodeKind::FRAGMENT_DEFINITION: array_pop($this->typeStack); break; - case NodeType::VARIABLE_DEFINITION: + case NodeKind::VARIABLE_DEFINITION: array_pop($this->inputTypeStack); break; - case NodeType::ARGUMENT: + case NodeKind::ARGUMENT: $this->argument = null; array_pop($this->inputTypeStack); break; - case NodeType::LST: - case NodeType::OBJECT_FIELD: + case NodeKind::LST: + case NodeKind::OBJECT_FIELD: array_pop($this->inputTypeStack); break; } diff --git a/src/Validator/DocumentValidator.php b/src/Validator/DocumentValidator.php index 1fbacac..540765d 100644 --- a/src/Validator/DocumentValidator.php +++ b/src/Validator/DocumentValidator.php @@ -7,7 +7,7 @@ use GraphQL\Language\AST\ListValueNode; use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NullValueNode; use GraphQL\Language\AST\ValueNode; use GraphQL\Language\AST\VariableNode; @@ -195,7 +195,7 @@ class DocumentValidator // Input objects check each defined field and look for undefined fields. if ($type instanceof InputObjectType) { - if ($valueNode->kind !== NodeType::OBJECT) { + if ($valueNode->kind !== NodeKind::OBJECT) { return [ "Expected \"{$type->name}\", found not an object." ]; } diff --git a/src/Validator/Rules/AbstractQuerySecurity.php b/src/Validator/Rules/AbstractQuerySecurity.php index 0d7212a..ef0d4a0 100644 --- a/src/Validator/Rules/AbstractQuerySecurity.php +++ b/src/Validator/Rules/AbstractQuerySecurity.php @@ -7,7 +7,7 @@ use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Type\Definition\Type; use GraphQL\Type\Introspection; @@ -100,7 +100,7 @@ abstract class AbstractQuerySecurity foreach ($selectionSet->selections as $selection) { switch ($selection->kind) { - case NodeType::FIELD: + case NodeKind::FIELD: /* @var FieldNode $selection */ $fieldName = $selection->name->value; $fieldDef = null; @@ -127,7 +127,7 @@ abstract class AbstractQuerySecurity // create field context $_astAndDefs[$responseName][] = [$selection, $fieldDef]; break; - case NodeType::INLINE_FRAGMENT: + case NodeKind::INLINE_FRAGMENT: /* @var InlineFragmentNode $selection */ $_astAndDefs = $this->collectFieldASTsAndDefs( $context, @@ -137,7 +137,7 @@ abstract class AbstractQuerySecurity $_astAndDefs ); break; - case NodeType::FRAGMENT_SPREAD: + case NodeKind::FRAGMENT_SPREAD: /* @var FragmentSpreadNode $selection */ $fragName = $selection->name->value; diff --git a/src/Validator/Rules/ArgumentsOfCorrectType.php b/src/Validator/Rules/ArgumentsOfCorrectType.php index ec03d92..870eaf6 100644 --- a/src/Validator/Rules/ArgumentsOfCorrectType.php +++ b/src/Validator/Rules/ArgumentsOfCorrectType.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Printer; use GraphQL\Language\Visitor; use GraphQL\Type\Definition\NonNull; @@ -26,7 +26,7 @@ class ArgumentsOfCorrectType public function __invoke(ValidationContext $context) { return [ - NodeType::ARGUMENT => function(ArgumentNode $argNode) use ($context) { + NodeKind::ARGUMENT => function(ArgumentNode $argNode) use ($context) { $argDef = $context->getArgument(); if ($argDef) { $errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argNode->value); diff --git a/src/Validator/Rules/DefaultValuesOfCorrectType.php b/src/Validator/Rules/DefaultValuesOfCorrectType.php index cb12431..b8f1b1d 100644 --- a/src/Validator/Rules/DefaultValuesOfCorrectType.php +++ b/src/Validator/Rules/DefaultValuesOfCorrectType.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\VariableDefinitionNode; use GraphQL\Language\Printer; use GraphQL\Language\Visitor; @@ -30,7 +30,7 @@ class DefaultValuesOfCorrectType public function __invoke(ValidationContext $context) { return [ - NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) use ($context) { + NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefNode) use ($context) { $name = $varDefNode->variable->name->value; $defaultValue = $varDefNode->defaultValue; $type = $context->getInputType(); @@ -52,8 +52,8 @@ class DefaultValuesOfCorrectType } return Visitor::skipNode(); }, - NodeType::SELECTION_SET => function() {return Visitor::skipNode();}, - NodeType::FRAGMENT_DEFINITION => function() {return Visitor::skipNode();} + NodeKind::SELECTION_SET => function() {return Visitor::skipNode();}, + NodeKind::FRAGMENT_DEFINITION => function() {return Visitor::skipNode();} ]; } } diff --git a/src/Validator/Rules/FieldsOnCorrectType.php b/src/Validator/Rules/FieldsOnCorrectType.php index 91327b9..3720040 100644 --- a/src/Validator/Rules/FieldsOnCorrectType.php +++ b/src/Validator/Rules/FieldsOnCorrectType.php @@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Schema; use GraphQL\Type\Definition\AbstractType; use GraphQL\Utils; @@ -37,7 +37,7 @@ class FieldsOnCorrectType public function __invoke(ValidationContext $context) { return [ - NodeType::FIELD => function(FieldNode $node) use ($context) { + NodeKind::FIELD => function(FieldNode $node) use ($context) { $type = $context->getParentType(); if ($type) { $fieldDef = $context->getFieldDef(); diff --git a/src/Validator/Rules/FragmentsOnCompositeTypes.php b/src/Validator/Rules/FragmentsOnCompositeTypes.php index ae85700..6eeffa8 100644 --- a/src/Validator/Rules/FragmentsOnCompositeTypes.php +++ b/src/Validator/Rules/FragmentsOnCompositeTypes.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Printer; use GraphQL\Type\Definition\CompositeType; use GraphQL\Type\Definition\Type; @@ -28,7 +28,7 @@ class FragmentsOnCompositeTypes public function __invoke(ValidationContext $context) { return [ - NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) { + NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) { $type = $context->getType(); 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(); if ($type && !Type::isCompositeType($type)) { diff --git a/src/Validator/Rules/KnownArgumentNames.php b/src/Validator/Rules/KnownArgumentNames.php index 320da9e..f11673f 100644 --- a/src/Validator/Rules/KnownArgumentNames.php +++ b/src/Validator/Rules/KnownArgumentNames.php @@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Utils; use GraphQL\Validator\Messages; use GraphQL\Validator\ValidationContext; @@ -25,9 +25,9 @@ class KnownArgumentNames public function __invoke(ValidationContext $context) { 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]; - if ($argumentOf->kind === NodeType::FIELD) { + if ($argumentOf->kind === NodeKind::FIELD) { $fieldDef = $context->getFieldDef(); if ($fieldDef) { @@ -47,7 +47,7 @@ class KnownArgumentNames )); } } - } else if ($argumentOf->kind === NodeType::DIRECTIVE) { + } else if ($argumentOf->kind === NodeKind::DIRECTIVE) { $directive = $context->getDirective(); if ($directive) { $directiveArgDef = null; diff --git a/src/Validator/Rules/KnownDirectives.php b/src/Validator/Rules/KnownDirectives.php index a41c463..1dc12cb 100644 --- a/src/Validator/Rules/KnownDirectives.php +++ b/src/Validator/Rules/KnownDirectives.php @@ -9,7 +9,7 @@ use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Validator\Messages; use GraphQL\Validator\ValidationContext; @@ -30,7 +30,7 @@ class KnownDirectives public function __invoke(ValidationContext $context) { 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; foreach ($context->getSchema()->getDirectives() as $def) { if ($def->name === $node->name->value) { @@ -67,17 +67,17 @@ class KnownDirectives private function getLocationForAppliedNode(Node $appliedTo) { switch ($appliedTo->kind) { - case NodeType::OPERATION_DEFINITION: + case NodeKind::OPERATION_DEFINITION: switch ($appliedTo->operation) { case 'query': return DirectiveDef::LOCATION_QUERY; case 'mutation': return DirectiveDef::LOCATION_MUTATION; case 'subscription': return DirectiveDef::LOCATION_SUBSCRIPTION; } break; - case NodeType::FIELD: return DirectiveDef::LOCATION_FIELD; - case NodeType::FRAGMENT_SPREAD: return DirectiveDef::LOCATION_FRAGMENT_SPREAD; - case NodeType::INLINE_FRAGMENT: return DirectiveDef::LOCATION_INLINE_FRAGMENT; - case NodeType::FRAGMENT_DEFINITION: return DirectiveDef::LOCATION_FRAGMENT_DEFINITION; + case NodeKind::FIELD: return DirectiveDef::LOCATION_FIELD; + case NodeKind::FRAGMENT_SPREAD: return DirectiveDef::LOCATION_FRAGMENT_SPREAD; + case NodeKind::INLINE_FRAGMENT: return DirectiveDef::LOCATION_INLINE_FRAGMENT; + case NodeKind::FRAGMENT_DEFINITION: return DirectiveDef::LOCATION_FRAGMENT_DEFINITION; } } } diff --git a/src/Validator/Rules/KnownFragmentNames.php b/src/Validator/Rules/KnownFragmentNames.php index 9f57826..39e5858 100644 --- a/src/Validator/Rules/KnownFragmentNames.php +++ b/src/Validator/Rules/KnownFragmentNames.php @@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Validator\ValidationContext; class KnownFragmentNames @@ -18,7 +18,7 @@ class KnownFragmentNames public function __invoke(ValidationContext $context) { return [ - NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) { + NodeKind::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) { $fragmentName = $node->name->value; $fragment = $context->getFragment($fragmentName); if (!$fragment) { diff --git a/src/Validator/Rules/KnownTypeNames.php b/src/Validator/Rules/KnownTypeNames.php index ed5bde5..7ca22d8 100644 --- a/src/Validator/Rules/KnownTypeNames.php +++ b/src/Validator/Rules/KnownTypeNames.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\NamedTypeNode; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Validator\ValidationContext; @@ -20,12 +20,12 @@ class KnownTypeNames $skip = function() {return Visitor::skipNode();}; return [ - NodeType::OBJECT_TYPE_DEFINITION => $skip, - NodeType::INTERFACE_TYPE_DEFINITION => $skip, - NodeType::UNION_TYPE_DEFINITION => $skip, - NodeType::INPUT_OBJECT_TYPE_DEFINITION => $skip, + NodeKind::OBJECT_TYPE_DEFINITION => $skip, + NodeKind::INTERFACE_TYPE_DEFINITION => $skip, + NodeKind::UNION_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; $type = $context->getSchema()->getType($typeName); if (!$type) { diff --git a/src/Validator/Rules/LoneAnonymousOperation.php b/src/Validator/Rules/LoneAnonymousOperation.php index 7ef500b..3a9ab6d 100644 --- a/src/Validator/Rules/LoneAnonymousOperation.php +++ b/src/Validator/Rules/LoneAnonymousOperation.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Utils; use GraphQL\Validator\ValidationContext; @@ -26,16 +26,16 @@ class LoneAnonymousOperation { $operationCount = 0; return [ - NodeType::DOCUMENT => function(DocumentNode $node) use (&$operationCount) { + NodeKind::DOCUMENT => function(DocumentNode $node) use (&$operationCount) { $tmp = Utils::filter( $node->definitions, function ($definition) { - return $definition->kind === NodeType::OPERATION_DEFINITION; + return $definition->kind === NodeKind::OPERATION_DEFINITION; } ); $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) { $context->reportError( new Error(self::anonOperationNotAloneMessage(), [$node]) diff --git a/src/Validator/Rules/NoFragmentCycles.php b/src/Validator/Rules/NoFragmentCycles.php index 59e22f9..d98ce9b 100644 --- a/src/Validator/Rules/NoFragmentCycles.php +++ b/src/Validator/Rules/NoFragmentCycles.php @@ -13,7 +13,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Utils; use GraphQL\Validator\ValidationContext; @@ -45,10 +45,10 @@ class NoFragmentCycles $this->spreadPathIndexByName = []; return [ - NodeType::OPERATION_DEFINITION => function () { + NodeKind::OPERATION_DEFINITION => function () { 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])) { $this->detectCycleRecursive($node, $context); } diff --git a/src/Validator/Rules/NoUndefinedVariables.php b/src/Validator/Rules/NoUndefinedVariables.php index c06a325..98a0c38 100644 --- a/src/Validator/Rules/NoUndefinedVariables.php +++ b/src/Validator/Rules/NoUndefinedVariables.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\VariableNode; use GraphQL\Language\AST\VariableDefinitionNode; @@ -36,7 +36,7 @@ class NoUndefinedVariables $variableNameDefined = []; return [ - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'enter' => function() use (&$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; } ]; diff --git a/src/Validator/Rules/NoUnusedFragments.php b/src/Validator/Rules/NoUnusedFragments.php index 42b284f..9c3c74d 100644 --- a/src/Validator/Rules/NoUnusedFragments.php +++ b/src/Validator/Rules/NoUnusedFragments.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Validator\Messages; use GraphQL\Validator\ValidationContext; @@ -28,15 +28,15 @@ class NoUnusedFragments $this->fragmentDefs = []; return [ - NodeType::OPERATION_DEFINITION => function($node) { + NodeKind::OPERATION_DEFINITION => function($node) { $this->operationDefs[] = $node; return Visitor::skipNode(); }, - NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) { + NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) { $this->fragmentDefs[] = $def; return Visitor::skipNode(); }, - NodeType::DOCUMENT => [ + NodeKind::DOCUMENT => [ 'leave' => function() use ($context) { $fragmentNameUsed = []; diff --git a/src/Validator/Rules/NoUnusedVariables.php b/src/Validator/Rules/NoUnusedVariables.php index 40d2f32..ec1bc9b 100644 --- a/src/Validator/Rules/NoUnusedVariables.php +++ b/src/Validator/Rules/NoUnusedVariables.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\Visitor; use GraphQL\Validator\Messages; @@ -26,7 +26,7 @@ class NoUnusedVariables $this->variableDefs = []; return [ - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'enter' => function() { $this->variableDefs = []; }, @@ -52,7 +52,7 @@ class NoUnusedVariables } } ], - NodeType::VARIABLE_DEFINITION => function($def) { + NodeKind::VARIABLE_DEFINITION => function($def) { $this->variableDefs[] = $def; } ]; diff --git a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php index 5470335..2edcabe 100644 --- a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php +++ b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php @@ -10,7 +10,7 @@ use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\NamedTypeNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Language\Printer; use GraphQL\Type\Definition\ListOfType; @@ -54,7 +54,7 @@ class OverlappingFieldsCanBeMerged $this->comparedSet = new PairSet(); return [ - NodeType::SELECTION_SET => [ + NodeKind::SELECTION_SET => [ // Note: we validate on the reverse traversal so deeper conflicts will be // caught first, for clearer error messages. 'leave' => function(SelectionSetNode $selectionSet) use ($context) { @@ -318,7 +318,7 @@ class OverlappingFieldsCanBeMerged $selection = $selectionSet->selections[$i]; switch ($selection->kind) { - case NodeType::FIELD: + case NodeKind::FIELD: $fieldName = $selection->name->value; $fieldDef = null; if ($parentType && method_exists($parentType, 'getFields')) { @@ -334,7 +334,7 @@ class OverlappingFieldsCanBeMerged } $_astAndDefs[$responseName][] = [$parentType, $selection, $fieldDef]; break; - case NodeType::INLINE_FRAGMENT: + case NodeKind::INLINE_FRAGMENT: $typeCondition = $selection->typeCondition; $inlineFragmentType = $typeCondition ? TypeInfo::typeFromAST($context->getSchema(), $typeCondition) @@ -348,7 +348,7 @@ class OverlappingFieldsCanBeMerged $_astAndDefs ); break; - case NodeType::FRAGMENT_SPREAD: + case NodeKind::FRAGMENT_SPREAD: /** @var FragmentSpreadNode $selection */ $fragName = $selection->name->value; if (!empty($_visitedFragmentNames[$fragName])) { diff --git a/src/Validator/Rules/PossibleFragmentSpreads.php b/src/Validator/Rules/PossibleFragmentSpreads.php index 144d568..8d910dc 100644 --- a/src/Validator/Rules/PossibleFragmentSpreads.php +++ b/src/Validator/Rules/PossibleFragmentSpreads.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Utils; use GraphQL\Validator\ValidationContext; use GraphQL\Utils\TypeInfo; @@ -26,7 +26,7 @@ class PossibleFragmentSpreads public function __invoke(ValidationContext $context) { return [ - NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) { + NodeKind::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) { $fragType = $context->getType(); $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; $fragType = $this->getFragmentType($context, $fragName); $parentType = $context->getParentType(); diff --git a/src/Validator/Rules/ProvidedNonNullArguments.php b/src/Validator/Rules/ProvidedNonNullArguments.php index 7271395..ecc3d65 100644 --- a/src/Validator/Rules/ProvidedNonNullArguments.php +++ b/src/Validator/Rules/ProvidedNonNullArguments.php @@ -6,7 +6,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\DirectiveNode; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Type\Definition\NonNull; use GraphQL\Utils; @@ -27,7 +27,7 @@ class ProvidedNonNullArguments public function __invoke(ValidationContext $context) { return [ - NodeType::FIELD => [ + NodeKind::FIELD => [ 'leave' => function(FieldNode $fieldNode) use ($context) { $fieldDef = $context->getFieldDef(); @@ -51,7 +51,7 @@ class ProvidedNonNullArguments } } ], - NodeType::DIRECTIVE => [ + NodeKind::DIRECTIVE => [ 'leave' => function(DirectiveNode $directiveNode) use ($context) { $directiveDef = $context->getDirective(); if (!$directiveDef) { diff --git a/src/Validator/Rules/QueryComplexity.php b/src/Validator/Rules/QueryComplexity.php index d4701c1..b290da7 100644 --- a/src/Validator/Rules/QueryComplexity.php +++ b/src/Validator/Rules/QueryComplexity.php @@ -8,7 +8,7 @@ use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Language\Visitor; @@ -78,7 +78,7 @@ class QueryComplexity extends AbstractQuerySecurity return $this->invokeIfNeeded( $context, [ - NodeType::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) { + NodeKind::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) { $this->fieldNodeAndDefs = $this->collectFieldASTsAndDefs( $context, $context->getParentType(), @@ -87,11 +87,11 @@ class QueryComplexity extends AbstractQuerySecurity $this->fieldNodeAndDefs ); }, - NodeType::VARIABLE_DEFINITION => function ($def) { + NodeKind::VARIABLE_DEFINITION => function ($def) { $this->variableDefs[] = $def; return Visitor::skipNode(); }, - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) { $complexity = $this->fieldComplexity($operationDefinition, $complexity); @@ -120,7 +120,7 @@ class QueryComplexity extends AbstractQuerySecurity private function nodeComplexity(Node $node, $complexity = 0) { switch ($node->kind) { - case NodeType::FIELD: + case NodeKind::FIELD: /* @var FieldNode $node */ // default values $args = []; @@ -148,7 +148,7 @@ class QueryComplexity extends AbstractQuerySecurity $complexity += call_user_func_array($complexityFn, [$childrenComplexity, $args]); break; - case NodeType::INLINE_FRAGMENT: + case NodeKind::INLINE_FRAGMENT: /* @var InlineFragmentNode $node */ // node has children? if (isset($node->selectionSet)) { @@ -156,7 +156,7 @@ class QueryComplexity extends AbstractQuerySecurity } break; - case NodeType::FRAGMENT_SPREAD: + case NodeKind::FRAGMENT_SPREAD: /* @var FragmentSpreadNode $node */ $fragment = $this->getFragment($node); diff --git a/src/Validator/Rules/QueryDepth.php b/src/Validator/Rules/QueryDepth.php index f571d02..ca0a8df 100644 --- a/src/Validator/Rules/QueryDepth.php +++ b/src/Validator/Rules/QueryDepth.php @@ -6,7 +6,7 @@ use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\InlineFragmentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Validator\ValidationContext; @@ -50,7 +50,7 @@ class QueryDepth extends AbstractQuerySecurity return $this->invokeIfNeeded( $context, [ - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) { $maxDepth = $this->fieldDepth($operationDefinition); @@ -84,7 +84,7 @@ class QueryDepth extends AbstractQuerySecurity private function nodeDepth(Node $node, $depth = 0, $maxDepth = 0) { switch ($node->kind) { - case NodeType::FIELD: + case NodeKind::FIELD: /* @var FieldNode $node */ // node has children? if (null !== $node->selectionSet) { @@ -96,7 +96,7 @@ class QueryDepth extends AbstractQuerySecurity } break; - case NodeType::INLINE_FRAGMENT: + case NodeKind::INLINE_FRAGMENT: /* @var InlineFragmentNode $node */ // node has children? if (null !== $node->selectionSet) { @@ -104,7 +104,7 @@ class QueryDepth extends AbstractQuerySecurity } break; - case NodeType::FRAGMENT_SPREAD: + case NodeKind::FRAGMENT_SPREAD: /* @var FragmentSpreadNode $node */ $fragment = $this->getFragment($node); diff --git a/src/Validator/Rules/ScalarLeafs.php b/src/Validator/Rules/ScalarLeafs.php index f46bd91..9daf8ab 100644 --- a/src/Validator/Rules/ScalarLeafs.php +++ b/src/Validator/Rules/ScalarLeafs.php @@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Type\Definition\Type; use GraphQL\Validator\Messages; use GraphQL\Validator\ValidationContext; @@ -25,7 +25,7 @@ class ScalarLeafs public function __invoke(ValidationContext $context) { return [ - NodeType::FIELD => function(FieldNode $node) use ($context) { + NodeKind::FIELD => function(FieldNode $node) use ($context) { $type = $context->getType(); if ($type) { if (Type::isLeafType($type)) { diff --git a/src/Validator/Rules/UniqueArgumentNames.php b/src/Validator/Rules/UniqueArgumentNames.php index cee0d04..6c4f5c2 100644 --- a/src/Validator/Rules/UniqueArgumentNames.php +++ b/src/Validator/Rules/UniqueArgumentNames.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Validator\ValidationContext; @@ -22,13 +22,13 @@ class UniqueArgumentNames $this->knownArgNames = []; return [ - NodeType::FIELD => function () { + NodeKind::FIELD => function () { $this->knownArgNames = [];; }, - NodeType::DIRECTIVE => function () { + NodeKind::DIRECTIVE => function () { $this->knownArgNames = []; }, - NodeType::ARGUMENT => function (ArgumentNode $node) use ($context) { + NodeKind::ARGUMENT => function (ArgumentNode $node) use ($context) { $argName = $node->name->value; if (!empty($this->knownArgNames[$argName])) { $context->reportError(new Error( diff --git a/src/Validator/Rules/UniqueFragmentNames.php b/src/Validator/Rules/UniqueFragmentNames.php index 5cf63be..20422e3 100644 --- a/src/Validator/Rules/UniqueFragmentNames.php +++ b/src/Validator/Rules/UniqueFragmentNames.php @@ -5,7 +5,7 @@ use GraphQL\Error\Error; use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\FragmentDefinitionNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\Visitor; use GraphQL\Validator\ValidationContext; @@ -23,10 +23,10 @@ class UniqueFragmentNames $this->knownFragmentNames = []; return [ - NodeType::OPERATION_DEFINITION => function () { + NodeKind::OPERATION_DEFINITION => function () { return Visitor::skipNode(); }, - NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) { + NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) { $fragmentName = $node->name->value; if (!empty($this->knownFragmentNames[$fragmentName])) { $context->reportError(new Error( diff --git a/src/Validator/Rules/UniqueInputFieldNames.php b/src/Validator/Rules/UniqueInputFieldNames.php index 4aa3015..cbc7b73 100644 --- a/src/Validator/Rules/UniqueInputFieldNames.php +++ b/src/Validator/Rules/UniqueInputFieldNames.php @@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\ObjectFieldNode; use GraphQL\Language\Visitor; use GraphQL\Validator\ValidationContext; @@ -24,7 +24,7 @@ class UniqueInputFieldNames $this->knownNameStack = []; return [ - NodeType::OBJECT => [ + NodeKind::OBJECT => [ 'enter' => function() { $this->knownNameStack[] = $this->knownNames; $this->knownNames = []; @@ -33,7 +33,7 @@ class UniqueInputFieldNames $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; if (!empty($this->knownNames[$fieldName])) { diff --git a/src/Validator/Rules/UniqueOperationNames.php b/src/Validator/Rules/UniqueOperationNames.php index 8bc9217..27122b5 100644 --- a/src/Validator/Rules/UniqueOperationNames.php +++ b/src/Validator/Rules/UniqueOperationNames.php @@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\Visitor; use GraphQL\Validator\ValidationContext; @@ -22,7 +22,7 @@ class UniqueOperationNames $this->knownOperationNames = []; return [ - NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) { + NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) { $operationName = $node->name; if ($operationName) { @@ -37,7 +37,7 @@ class UniqueOperationNames } return Visitor::skipNode(); }, - NodeType::FRAGMENT_DEFINITION => function() { + NodeKind::FRAGMENT_DEFINITION => function() { return Visitor::skipNode(); } ]; diff --git a/src/Validator/Rules/UniqueVariableNames.php b/src/Validator/Rules/UniqueVariableNames.php index 8bb27b4..ee6267a 100644 --- a/src/Validator/Rules/UniqueVariableNames.php +++ b/src/Validator/Rules/UniqueVariableNames.php @@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\VariableDefinitionNode; use GraphQL\Validator\ValidationContext; @@ -21,10 +21,10 @@ class UniqueVariableNames $this->knownVariableNames = []; return [ - NodeType::OPERATION_DEFINITION => function() { + NodeKind::OPERATION_DEFINITION => function() { $this->knownVariableNames = []; }, - NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) { + NodeKind::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) { $variableName = $node->variable->name->value; if (!empty($this->knownVariableNames[$variableName])) { $context->reportError(new Error( diff --git a/src/Validator/Rules/VariablesAreInputTypes.php b/src/Validator/Rules/VariablesAreInputTypes.php index 6251ff5..f44e889 100644 --- a/src/Validator/Rules/VariablesAreInputTypes.php +++ b/src/Validator/Rules/VariablesAreInputTypes.php @@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\VariableDefinitionNode; use GraphQL\Language\Printer; use GraphQL\Type\Definition\InputType; @@ -22,7 +22,7 @@ class VariablesAreInputTypes public function __invoke(ValidationContext $context) { 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); // If the variable type is not an input type, return an error. diff --git a/src/Validator/Rules/VariablesInAllowedPosition.php b/src/Validator/Rules/VariablesInAllowedPosition.php index 2f6c06b..2fe0724 100644 --- a/src/Validator/Rules/VariablesInAllowedPosition.php +++ b/src/Validator/Rules/VariablesInAllowedPosition.php @@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules; use GraphQL\Error\Error; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\VariableNode; use GraphQL\Language\AST\VariableDefinitionNode; @@ -29,7 +29,7 @@ class VariablesInAllowedPosition public function __invoke(ValidationContext $context) { return [ - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'enter' => function () { $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; } ]; diff --git a/src/Validator/ValidationContext.php b/src/Validator/ValidationContext.php index 68d83ad..0e20399 100644 --- a/src/Validator/ValidationContext.php +++ b/src/Validator/ValidationContext.php @@ -3,7 +3,7 @@ namespace GraphQL\Validator; use GraphQL\Language\AST\FragmentSpreadNode; use GraphQL\Language\AST\HasSelectionSet; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\VariableNode; use GraphQL\Language\Visitor; @@ -133,7 +133,7 @@ class ValidationContext if (!$fragments) { $this->fragments = $fragments = 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; } return $frags; @@ -157,7 +157,7 @@ class ValidationContext for ($i = 0; $i < count($set->selections); $i++) { $selection = $set->selections[$i]; - if ($selection->kind === NodeType::FRAGMENT_SPREAD) { + if ($selection->kind === NodeKind::FRAGMENT_SPREAD) { $spreads[] = $selection; } else if ($selection->selectionSet) { $setsToVisit[] = $selection->selectionSet; @@ -214,10 +214,10 @@ class ValidationContext $newUsages = []; $typeInfo = new TypeInfo($this->schema); Visitor::visit($node, Visitor::visitWithTypeInfo($typeInfo, [ - NodeType::VARIABLE_DEFINITION => function () { + NodeKind::VARIABLE_DEFINITION => function () { return false; }, - NodeType::VARIABLE => function (VariableNode $variable) use (&$newUsages, $typeInfo) { + NodeKind::VARIABLE => function (VariableNode $variable) use (&$newUsages, $typeInfo) { $newUsages[] = ['node' => $variable, 'type' => $typeInfo->getInputType()]; } ])); diff --git a/tests/Language/ParserTest.php b/tests/Language/ParserTest.php index b1a1d2c..8c7f1d4 100644 --- a/tests/Language/ParserTest.php +++ b/tests/Language/ParserTest.php @@ -5,7 +5,7 @@ use GraphQL\Language\AST\ArgumentNode; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\NameNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NullValueNode; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Language\AST\StringValueNode; @@ -259,39 +259,39 @@ fragment $fragmentName on Type { }; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'loc' => $loc(0, 41), 'definitions' => [ [ - 'kind' => NodeType::OPERATION_DEFINITION, + 'kind' => NodeKind::OPERATION_DEFINITION, 'loc' => $loc(0, 40), 'operation' => 'query', 'name' => null, 'variableDefinitions' => null, 'directives' => [], 'selectionSet' => [ - 'kind' => NodeType::SELECTION_SET, + 'kind' => NodeKind::SELECTION_SET, 'loc' => $loc(0, 40), 'selections' => [ [ - 'kind' => NodeType::FIELD, + 'kind' => NodeKind::FIELD, 'loc' => $loc(4, 38), 'alias' => null, 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => $loc(4, 8), 'value' => 'node' ], 'arguments' => [ [ - 'kind' => NodeType::ARGUMENT, + 'kind' => NodeKind::ARGUMENT, 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => $loc(9, 11), 'value' => 'id' ], 'value' => [ - 'kind' => NodeType::INT, + 'kind' => NodeKind::INT, 'loc' => $loc(13, 14), 'value' => '4' ], @@ -300,15 +300,15 @@ fragment $fragmentName on Type { ], 'directives' => [], 'selectionSet' => [ - 'kind' => NodeType::SELECTION_SET, + 'kind' => NodeKind::SELECTION_SET, 'loc' => $loc(16, 38), 'selections' => [ [ - 'kind' => NodeType::FIELD, + 'kind' => NodeKind::FIELD, 'loc' => $loc(22, 24), 'alias' => null, 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => $loc(22, 24), 'value' => 'id' ], @@ -317,11 +317,11 @@ fragment $fragmentName on Type { 'selectionSet' => null ], [ - 'kind' => NodeType::FIELD, + 'kind' => NodeKind::FIELD, 'loc' => $loc(30, 34), 'alias' => null, 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => $loc(30, 34), 'value' => 'name' ], @@ -391,7 +391,7 @@ fragment $fragmentName on Type { public function testParsesNullValues() { $this->assertEquals([ - 'kind' => NodeType::NULL, + 'kind' => NodeKind::NULL, 'loc' => ['start' => 0, 'end' => 4] ], $this->nodeToArray(Parser::parseValue('null'))); } @@ -402,16 +402,16 @@ fragment $fragmentName on Type { public function testParsesListValues() { $this->assertEquals([ - 'kind' => NodeType::LST, + 'kind' => NodeKind::LST, 'loc' => ['start' => 0, 'end' => 11], 'values' => [ [ - 'kind' => NodeType::INT, + 'kind' => NodeKind::INT, 'loc' => ['start' => 1, 'end' => 4], 'value' => '123' ], [ - 'kind' => NodeType::STRING, + 'kind' => NodeKind::STRING, 'loc' => ['start' => 5, 'end' => 10], 'value' => 'abc' ] @@ -427,10 +427,10 @@ fragment $fragmentName on Type { public function testParsesWellKnownTypes() { $this->assertEquals([ - 'kind' => NodeType::NAMED_TYPE, + 'kind' => NodeKind::NAMED_TYPE, 'loc' => ['start' => 0, 'end' => 6], 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => ['start' => 0, 'end' => 6], 'value' => 'String' ] @@ -443,10 +443,10 @@ fragment $fragmentName on Type { public function testParsesCustomTypes() { $this->assertEquals([ - 'kind' => NodeType::NAMED_TYPE, + 'kind' => NodeKind::NAMED_TYPE, 'loc' => ['start' => 0, 'end' => 6], 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => ['start' => 0, 'end' => 6], 'value' => 'MyType' ] @@ -459,13 +459,13 @@ fragment $fragmentName on Type { public function testParsesListTypes() { $this->assertEquals([ - 'kind' => NodeType::LIST_TYPE, + 'kind' => NodeKind::LIST_TYPE, 'loc' => ['start' => 0, 'end' => 8], 'type' => [ - 'kind' => NodeType::NAMED_TYPE, + 'kind' => NodeKind::NAMED_TYPE, 'loc' => ['start' => 1, 'end' => 7], 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => ['start' => 1, 'end' => 7], 'value' => 'MyType' ] @@ -479,13 +479,13 @@ fragment $fragmentName on Type { public function testParsesNonNullTypes() { $this->assertEquals([ - 'kind' => NodeType::NON_NULL_TYPE, + 'kind' => NodeKind::NON_NULL_TYPE, 'loc' => ['start' => 0, 'end' => 7], 'type' => [ - 'kind' => NodeType::NAMED_TYPE, + 'kind' => NodeKind::NAMED_TYPE, 'loc' => ['start' => 0, 'end' => 6], 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => ['start' => 0, 'end' => 6], 'value' => 'MyType' ] @@ -499,16 +499,16 @@ fragment $fragmentName on Type { public function testParsesNestedTypes() { $this->assertEquals([ - 'kind' => NodeType::LIST_TYPE, + 'kind' => NodeKind::LIST_TYPE, 'loc' => ['start' => 0, 'end' => 9], 'type' => [ - 'kind' => NodeType::NON_NULL_TYPE, + 'kind' => NodeKind::NON_NULL_TYPE, 'loc' => ['start' => 1, 'end' => 8], 'type' => [ - 'kind' => NodeType::NAMED_TYPE, + 'kind' => NodeKind::NAMED_TYPE, 'loc' => ['start' => 1, 'end' => 7], 'name' => [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'loc' => ['start' => 1, 'end' => 7], 'value' => 'MyType' ] diff --git a/tests/Language/SchemaParserTest.php b/tests/Language/SchemaParserTest.php index aaba973..fd10108 100644 --- a/tests/Language/SchemaParserTest.php +++ b/tests/Language/SchemaParserTest.php @@ -14,7 +14,7 @@ use GraphQL\Language\AST\Location; use GraphQL\Language\AST\NameNode; use GraphQL\Language\AST\NamedTypeNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\NonNullTypeNode; use GraphQL\Language\AST\ObjectTypeDefinitionNode; use GraphQL\Language\AST\ScalarTypeDefinitionNode; @@ -40,10 +40,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'interfaces' => [], 'directives' => [], @@ -77,12 +77,12 @@ extend type Hello { return TestUtils::locArray($start, $end); }; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::TYPE_EXTENSION_DEFINITION, + 'kind' => NodeKind::TYPE_EXTENSION_DEFINITION, 'definition' => [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(13, 18)), 'interfaces' => [], 'directives' => [], @@ -118,10 +118,10 @@ type Hello { $doc = Parser::parse($body); $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6,11)), 'interfaces' => [], 'directives' => [], @@ -129,7 +129,7 @@ type Hello { $this->fieldNode( $this->nameNode('world', $loc(16, 21)), [ - 'kind' => NodeType::NON_NULL_TYPE, + 'kind' => NodeKind::NON_NULL_TYPE, 'type' => $this->typeNode('String', $loc(23, 29)), 'loc' => $loc(23, 30) ], @@ -155,10 +155,10 @@ type Hello { $doc = Parser::parse($body); $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(5, 10)), 'interfaces' => [ $this->typeNode('World', $loc(22, 27)) @@ -184,10 +184,10 @@ type Hello { $doc = Parser::parse($body); $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(5, 10)), 'interfaces' => [ $this->typeNode('Wo', $loc(22,24)), @@ -214,10 +214,10 @@ type Hello { $doc = Parser::parse($body); $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::ENUM_TYPE_DEFINITION, + 'kind' => NodeKind::ENUM_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(5, 10)), 'directives' => [], 'values' => [$this->enumValueNode('WORLD', $loc(13, 18))], @@ -240,10 +240,10 @@ type Hello { $doc = Parser::parse($body); $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::ENUM_TYPE_DEFINITION, + 'kind' => NodeKind::ENUM_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(5, 10)), 'directives' => [], 'values' => [ @@ -272,10 +272,10 @@ interface Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::INTERFACE_TYPE_DEFINITION, + 'kind' => NodeKind::INTERFACE_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(11, 16)), 'directives' => [], 'fields' => [ @@ -306,10 +306,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'interfaces' => [], 'directives' => [], @@ -350,10 +350,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'interfaces' => [], 'directives' => [], @@ -365,7 +365,7 @@ type Hello { $this->inputValueNode( $this->nameNode('flag', $loc(22, 26)), $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) ) ], @@ -393,10 +393,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'interfaces' => [], 'directives' => [], @@ -407,7 +407,7 @@ type Hello { [ $this->inputValueNode( $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, $loc(22, 38) ) @@ -437,10 +437,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'interfaces' => [], 'directives' => [], @@ -483,10 +483,10 @@ type Hello { $doc = Parser::parse($body); $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::UNION_TYPE_DEFINITION, + 'kind' => NodeKind::UNION_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'directives' => [], 'types' => [$this->typeNode('World', $loc(14, 19))], @@ -509,10 +509,10 @@ type Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::UNION_TYPE_DEFINITION, + 'kind' => NodeKind::UNION_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(6, 11)), 'directives' => [], 'types' => [ @@ -536,10 +536,10 @@ type Hello { $doc = Parser::parse($body); $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::SCALAR_TYPE_DEFINITION, + 'kind' => NodeKind::SCALAR_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(7, 12)), 'directives' => [], 'loc' => $loc(0, 12) @@ -563,10 +563,10 @@ input Hello { $loc = function($start, $end) {return TestUtils::locArray($start, $end);}; $expected = [ - 'kind' => NodeType::DOCUMENT, + 'kind' => NodeKind::DOCUMENT, 'definitions' => [ [ - 'kind' => NodeType::INPUT_OBJECT_TYPE_DEFINITION, + 'kind' => NodeKind::INPUT_OBJECT_TYPE_DEFINITION, 'name' => $this->nameNode('Hello', $loc(7, 12)), 'directives' => [], 'fields' => [ @@ -601,8 +601,8 @@ input Hello { private function typeNode($name, $loc) { return [ - 'kind' => NodeType::NAMED_TYPE, - 'name' => ['kind' => NodeType::NAME, 'value' => $name, 'loc' => $loc], + 'kind' => NodeKind::NAMED_TYPE, + 'name' => ['kind' => NodeKind::NAME, 'value' => $name, 'loc' => $loc], 'loc' => $loc ]; } @@ -610,7 +610,7 @@ input Hello { private function nameNode($name, $loc) { return [ - 'kind' => NodeType::NAME, + 'kind' => NodeKind::NAME, 'value' => $name, 'loc' => $loc ]; @@ -624,7 +624,7 @@ input Hello { private function fieldNodeWithArgs($name, $type, $args, $loc) { return [ - 'kind' => NodeType::FIELD_DEFINITION, + 'kind' => NodeKind::FIELD_DEFINITION, 'name' => $name, 'arguments' => $args, 'type' => $type, @@ -636,7 +636,7 @@ input Hello { private function enumValueNode($name, $loc) { return [ - 'kind' => NodeType::ENUM_VALUE_DEFINITION, + 'kind' => NodeKind::ENUM_VALUE_DEFINITION, 'name' => $this->nameNode($name, $loc), 'directives' => [], 'loc' => $loc @@ -646,7 +646,7 @@ input Hello { private function inputValueNode($name, $type, $defaultValue, $loc) { return [ - 'kind' => NodeType::INPUT_VALUE_DEFINITION, + 'kind' => NodeKind::INPUT_VALUE_DEFINITION, 'name' => $name, 'type' => $type, 'defaultValue' => $defaultValue, diff --git a/tests/Language/VisitorTest.php b/tests/Language/VisitorTest.php index bdf5023..162e166 100644 --- a/tests/Language/VisitorTest.php +++ b/tests/Language/VisitorTest.php @@ -5,7 +5,7 @@ use GraphQL\Language\AST\DocumentNode; use GraphQL\Language\AST\FieldNode; use GraphQL\Language\AST\NameNode; use GraphQL\Language\AST\Node; -use GraphQL\Language\AST\NodeType; +use GraphQL\Language\AST\NodeKind; use GraphQL\Language\AST\OperationDefinitionNode; use GraphQL\Language\AST\SelectionSetNode; use GraphQL\Language\Parser; @@ -26,7 +26,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase $selectionSet = null; $editedAst = Visitor::visit($ast, [ - NodeType::OPERATION_DEFINITION => [ + NodeKind::OPERATION_DEFINITION => [ 'enter' => function(OperationDefinitionNode $node) use (&$selectionSet) { $selectionSet = $node->selectionSet; @@ -64,7 +64,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase $definitions = $ast->definitions; $editedAst = Visitor::visit($ast, [ - NodeType::DOCUMENT => [ + NodeKind::DOCUMENT => [ 'enter' => function (DocumentNode $node) { $tmp = clone $node; $tmp->definitions = []; @@ -265,7 +265,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase 'leave' => function($node) use (&$visited) { $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(); } } @@ -298,10 +298,10 @@ class VisitorTest extends \PHPUnit_Framework_TestCase $ast = Parser::parse('{ a, b { x }, c }'); Visitor::visit($ast, [ - NodeType::NAME => function(NameNode $node) use (&$visited) { + NodeKind::NAME => function(NameNode $node) use (&$visited) { $visited[] = ['enter', $node->kind, $node->value]; }, - NodeType::SELECTION_SET => [ + NodeKind::SELECTION_SET => [ 'enter' => function(SelectionSetNode $node) use (&$visited) { $visited[] = ['enter', $node->kind, null]; },