mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 00:25:17 +03:00
move NodeTypes enum to seperate class
This commit is contained in:
parent
2e25f51829
commit
46788f2ddb
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Argument extends Node
|
class Argument extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::ARGUMENT;
|
public $kind = NodeType::ARGUMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Value
|
* @var Value
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class BooleanValue extends Node implements Value
|
class BooleanValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::BOOLEAN;
|
public $kind = NodeType::BOOLEAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Directive extends Node
|
class Directive extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::DIRECTIVE;
|
public $kind = NodeType::DIRECTIVE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class DirectiveDefinition extends Node implements TypeSystemDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::DIRECTIVE_DEFINITION;
|
public $kind = NodeType::DIRECTIVE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Document extends Node
|
class Document extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::DOCUMENT;
|
public $kind = NodeType::DOCUMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Definition[]
|
* @var Definition[]
|
||||||
|
@ -6,7 +6,7 @@ class EnumTypeDefinition extends Node implements TypeDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = self::ENUM_TYPE_DEFINITION;
|
public $kind = NodeType::ENUM_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class EnumValue extends Node implements Value
|
class EnumValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::ENUM;
|
public $kind = NodeType::ENUM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class EnumValueDefinition extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::ENUM_VALUE_DEFINITION;
|
public $kind = NodeType::ENUM_VALUE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Field extends Node implements Selection
|
class Field extends Node implements Selection
|
||||||
{
|
{
|
||||||
public $kind = Node::FIELD;
|
public $kind = NodeType::FIELD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class FieldDefinition extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::FIELD_DEFINITION;
|
public $kind = NodeType::FIELD_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
|
||||||
class FloatValue extends Node implements Value
|
class FloatValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::FLOAT;
|
public $kind = NodeType::FLOAT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
|
||||||
class FragmentDefinition extends Node implements Definition, HasSelectionSet
|
class FragmentDefinition extends Node implements Definition, HasSelectionSet
|
||||||
{
|
{
|
||||||
public $kind = Node::FRAGMENT_DEFINITION;
|
public $kind = NodeType::FRAGMENT_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class FragmentSpread extends Node implements Selection
|
class FragmentSpread extends Node implements Selection
|
||||||
{
|
{
|
||||||
public $kind = Node::FRAGMENT_SPREAD;
|
public $kind = NodeType::FRAGMENT_SPREAD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class InlineFragment extends Node implements Selection
|
class InlineFragment extends Node implements Selection
|
||||||
{
|
{
|
||||||
public $kind = Node::INLINE_FRAGMENT;
|
public $kind = NodeType::INLINE_FRAGMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NamedType
|
* @var NamedType
|
||||||
|
@ -6,7 +6,7 @@ class InputObjectTypeDefinition extends Node implements TypeDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::INPUT_OBJECT_TYPE_DEFINITION;
|
public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class InputValueDefinition extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::INPUT_VALUE_DEFINITION;
|
public $kind = NodeType::INPUT_VALUE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
|
||||||
class IntValue extends Node implements Value
|
class IntValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::INT;
|
public $kind = NodeType::INT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class InterfaceTypeDefinition extends Node implements TypeDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::INTERFACE_TYPE_DEFINITION;
|
public $kind = NodeType::INTERFACE_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ListType extends Node implements Type
|
class ListType extends Node implements Type
|
||||||
{
|
{
|
||||||
public $kind = Node::LIST_TYPE;
|
public $kind = NodeType::LIST_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Node
|
* @var Node
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
class ListValue extends Node implements Value
|
class ListValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::LST;
|
public $kind = NodeType::LST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<Value>
|
* @var array<Value>
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Name extends Node implements Type
|
class Name extends Node implements Type
|
||||||
{
|
{
|
||||||
public $kind = Node::NAME;
|
public $kind = NodeType::NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NamedType extends Node implements Type
|
class NamedType extends Node implements Type
|
||||||
{
|
{
|
||||||
public $kind = Node::NAMED_TYPE;
|
public $kind = NodeType::NAMED_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,78 +3,8 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Node
|
|
||||||
* @package GraphQL\Language\AST
|
|
||||||
*/
|
|
||||||
abstract class Node
|
abstract class Node
|
||||||
{
|
{
|
||||||
// constants from language/kinds.js:
|
|
||||||
|
|
||||||
const NAME = 'Name';
|
|
||||||
|
|
||||||
// Document
|
|
||||||
|
|
||||||
const DOCUMENT = 'Document';
|
|
||||||
const OPERATION_DEFINITION = 'OperationDefinition';
|
|
||||||
const VARIABLE_DEFINITION = 'VariableDefinition';
|
|
||||||
const VARIABLE = 'Variable';
|
|
||||||
const SELECTION_SET = 'SelectionSet';
|
|
||||||
const FIELD = 'Field';
|
|
||||||
const ARGUMENT = 'Argument';
|
|
||||||
|
|
||||||
// Fragments
|
|
||||||
|
|
||||||
const FRAGMENT_SPREAD = 'FragmentSpread';
|
|
||||||
const INLINE_FRAGMENT = 'InlineFragment';
|
|
||||||
const FRAGMENT_DEFINITION = 'FragmentDefinition';
|
|
||||||
|
|
||||||
// Values
|
|
||||||
|
|
||||||
const INT = 'IntValue';
|
|
||||||
const FLOAT = 'FloatValue';
|
|
||||||
const STRING = 'StringValue';
|
|
||||||
const BOOLEAN = 'BooleanValue';
|
|
||||||
const ENUM = 'EnumValue';
|
|
||||||
const LST = 'ListValue';
|
|
||||||
const OBJECT = 'ObjectValue';
|
|
||||||
const OBJECT_FIELD = 'ObjectField';
|
|
||||||
|
|
||||||
// Directives
|
|
||||||
|
|
||||||
const DIRECTIVE = 'Directive';
|
|
||||||
|
|
||||||
// Types
|
|
||||||
|
|
||||||
const NAMED_TYPE = 'NamedType';
|
|
||||||
const LIST_TYPE = 'ListType';
|
|
||||||
const NON_NULL_TYPE = 'NonNullType';
|
|
||||||
|
|
||||||
// Type System Definitions
|
|
||||||
|
|
||||||
const SCHEMA_DEFINITION = 'SchemaDefinition';
|
|
||||||
const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
|
|
||||||
|
|
||||||
// Type Definitions
|
|
||||||
|
|
||||||
const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
|
|
||||||
const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
|
|
||||||
const FIELD_DEFINITION = 'FieldDefinition';
|
|
||||||
const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
|
|
||||||
const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
|
|
||||||
const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
|
|
||||||
const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
|
|
||||||
const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
|
|
||||||
const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
|
|
||||||
|
|
||||||
// Type Extensions
|
|
||||||
|
|
||||||
const TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
|
|
||||||
|
|
||||||
// Directive Definitions
|
|
||||||
|
|
||||||
const DIRECTIVE_DEFINITION = 'DirectiveDefinition';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
type Node = Name
|
type Node = Name
|
||||||
| Document
|
| Document
|
||||||
|
72
src/Language/AST/NodeType.php
Normal file
72
src/Language/AST/NodeType.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
class NodeType
|
||||||
|
{
|
||||||
|
// constants from language/kinds.js:
|
||||||
|
|
||||||
|
const NAME = 'Name';
|
||||||
|
|
||||||
|
// Document
|
||||||
|
|
||||||
|
const DOCUMENT = 'Document';
|
||||||
|
const OPERATION_DEFINITION = 'OperationDefinition';
|
||||||
|
const VARIABLE_DEFINITION = 'VariableDefinition';
|
||||||
|
const VARIABLE = 'Variable';
|
||||||
|
const SELECTION_SET = 'SelectionSet';
|
||||||
|
const FIELD = 'Field';
|
||||||
|
const ARGUMENT = 'Argument';
|
||||||
|
|
||||||
|
// Fragments
|
||||||
|
|
||||||
|
const FRAGMENT_SPREAD = 'FragmentSpread';
|
||||||
|
const INLINE_FRAGMENT = 'InlineFragment';
|
||||||
|
const FRAGMENT_DEFINITION = 'FragmentDefinition';
|
||||||
|
|
||||||
|
// Values
|
||||||
|
|
||||||
|
const INT = 'IntValue';
|
||||||
|
const FLOAT = 'FloatValue';
|
||||||
|
const STRING = 'StringValue';
|
||||||
|
const BOOLEAN = 'BooleanValue';
|
||||||
|
const ENUM = 'EnumValue';
|
||||||
|
const LST = 'ListValue';
|
||||||
|
const OBJECT = 'ObjectValue';
|
||||||
|
const OBJECT_FIELD = 'ObjectField';
|
||||||
|
|
||||||
|
// Directives
|
||||||
|
|
||||||
|
const DIRECTIVE = 'Directive';
|
||||||
|
|
||||||
|
// Types
|
||||||
|
|
||||||
|
const NAMED_TYPE = 'NamedType';
|
||||||
|
const LIST_TYPE = 'ListType';
|
||||||
|
const NON_NULL_TYPE = 'NonNullType';
|
||||||
|
|
||||||
|
// Type System Definitions
|
||||||
|
|
||||||
|
const SCHEMA_DEFINITION = 'SchemaDefinition';
|
||||||
|
const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
|
||||||
|
|
||||||
|
// Type Definitions
|
||||||
|
|
||||||
|
const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
|
||||||
|
const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
|
||||||
|
const FIELD_DEFINITION = 'FieldDefinition';
|
||||||
|
const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
|
||||||
|
const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
|
||||||
|
const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
|
||||||
|
const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
|
||||||
|
const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
|
||||||
|
const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
|
||||||
|
|
||||||
|
// Type Extensions
|
||||||
|
|
||||||
|
const TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
|
||||||
|
|
||||||
|
// Directive Definitions
|
||||||
|
|
||||||
|
const DIRECTIVE_DEFINITION = 'DirectiveDefinition';
|
||||||
|
}
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class NonNullType extends Node implements Type
|
class NonNullType extends Node implements Type
|
||||||
{
|
{
|
||||||
public $kind = Node::NON_NULL_TYPE;
|
public $kind = NodeType::NON_NULL_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name | ListType
|
* @var Name | ListType
|
||||||
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ObjectField extends Node
|
class ObjectField extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::OBJECT_FIELD;
|
public $kind = NodeType::OBJECT_FIELD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class ObjectTypeDefinition extends Node implements TypeDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::OBJECT_TYPE_DEFINITION;
|
public $kind = NodeType::OBJECT_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class ObjectValue extends Node implements Value
|
class ObjectValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::OBJECT;
|
public $kind = NodeType::OBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<ObjectField>
|
* @var array<ObjectField>
|
||||||
|
@ -6,7 +6,7 @@ class OperationDefinition extends Node implements Definition, HasSelectionSet
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::OPERATION_DEFINITION;
|
public $kind = NodeType::OPERATION_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class OperationTypeDefinition extends Node
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::OPERATION_TYPE_DEFINITION;
|
public $kind = NodeType::OPERATION_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One of 'query' | 'mutation' | 'subscription'
|
* One of 'query' | 'mutation' | 'subscription'
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
|
||||||
class ScalarTypeDefinition extends Node implements TypeDefinition
|
class ScalarTypeDefinition extends Node implements TypeDefinition
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::SCALAR_TYPE_DEFINITION;
|
public $kind = NodeType::SCALAR_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -6,7 +6,7 @@ class SchemaDefinition extends Node implements TypeSystemDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::SCHEMA_DEFINITION;
|
public $kind = NodeType::SCHEMA_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Directive[]
|
* @var Directive[]
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class SelectionSet extends Node
|
class SelectionSet extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::SELECTION_SET;
|
public $kind = NodeType::SELECTION_SET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<Selection>
|
* @var array<Selection>
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language\AST;
|
namespace GraphQL\Language\AST;
|
||||||
|
|
||||||
|
|
||||||
class StringValue extends Node implements Value
|
class StringValue extends Node implements Value
|
||||||
{
|
{
|
||||||
public $kind = Node::STRING;
|
public $kind = NodeType::STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -6,7 +6,7 @@ class TypeExtensionDefinition extends Node implements TypeSystemDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = Node::TYPE_EXTENSION_DEFINITION;
|
public $kind = NodeType::TYPE_EXTENSION_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ObjectTypeDefinition
|
* @var ObjectTypeDefinition
|
||||||
|
@ -6,7 +6,7 @@ class UnionTypeDefinition extends Node implements TypeDefinition
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $kind = self::UNION_TYPE_DEFINITION;
|
public $kind = NodeType::UNION_TYPE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class Variable extends Node
|
class Variable extends Node
|
||||||
{
|
{
|
||||||
public $kind = Node::VARIABLE;
|
public $kind = NodeType::VARIABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Name
|
* @var Name
|
||||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Language\AST;
|
|||||||
|
|
||||||
class VariableDefinition extends Node implements Definition
|
class VariableDefinition extends Node implements Definition
|
||||||
{
|
{
|
||||||
public $kind = Node::VARIABLE_DEFINITION;
|
public $kind = NodeType::VARIABLE_DEFINITION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Variable
|
* @var Variable
|
||||||
|
@ -24,6 +24,7 @@ use GraphQL\Language\AST\IntValue;
|
|||||||
use GraphQL\Language\AST\ListType;
|
use GraphQL\Language\AST\ListType;
|
||||||
use GraphQL\Language\AST\NamedType;
|
use GraphQL\Language\AST\NamedType;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
|
use GraphQL\Language\AST\NodeType;
|
||||||
use GraphQL\Language\AST\NonNullType;
|
use GraphQL\Language\AST\NonNullType;
|
||||||
use GraphQL\Language\AST\ObjectField;
|
use GraphQL\Language\AST\ObjectField;
|
||||||
use GraphQL\Language\AST\ObjectTypeDefinition;
|
use GraphQL\Language\AST\ObjectTypeDefinition;
|
||||||
@ -44,16 +45,16 @@ class Printer
|
|||||||
{
|
{
|
||||||
return Visitor::visit($ast, [
|
return Visitor::visit($ast, [
|
||||||
'leave' => [
|
'leave' => [
|
||||||
Node::NAME => function($node) {
|
NodeType::NAME => function($node) {
|
||||||
return '' . $node->value;
|
return '' . $node->value;
|
||||||
},
|
},
|
||||||
Node::VARIABLE => function($node) {
|
NodeType::VARIABLE => function($node) {
|
||||||
return '$' . $node->name;
|
return '$' . $node->name;
|
||||||
},
|
},
|
||||||
Node::DOCUMENT => function(Document $node) {
|
NodeType::DOCUMENT => function(Document $node) {
|
||||||
return $this->join($node->definitions, "\n\n") . "\n";
|
return $this->join($node->definitions, "\n\n") . "\n";
|
||||||
},
|
},
|
||||||
Node::OPERATION_DEFINITION => function(OperationDefinition $node) {
|
NodeType::OPERATION_DEFINITION => function(OperationDefinition $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, ', '), ')');
|
||||||
@ -65,28 +66,28 @@ class Printer
|
|||||||
? $selectionSet
|
? $selectionSet
|
||||||
: $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');
|
: $this->join([$op, $this->join([$name, $varDefs]), $directives, $selectionSet], ' ');
|
||||||
},
|
},
|
||||||
Node::VARIABLE_DEFINITION => function(VariableDefinition $node) {
|
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) {
|
||||||
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
|
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
|
||||||
},
|
},
|
||||||
Node::SELECTION_SET => function(SelectionSet $node) {
|
NodeType::SELECTION_SET => function(SelectionSet $node) {
|
||||||
return $this->block($node->selections);
|
return $this->block($node->selections);
|
||||||
},
|
},
|
||||||
Node::FIELD => function(Field $node) {
|
NodeType::FIELD => function(Field $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
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::ARGUMENT => function(Argument $node) {
|
NodeType::ARGUMENT => function(Argument $node) {
|
||||||
return $node->name . ': ' . $node->value;
|
return $node->name . ': ' . $node->value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fragments
|
// Fragments
|
||||||
Node::FRAGMENT_SPREAD => function(FragmentSpread $node) {
|
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) {
|
||||||
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
|
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
|
||||||
},
|
},
|
||||||
Node::INLINE_FRAGMENT => function(InlineFragment $node) {
|
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
"...",
|
"...",
|
||||||
$this->wrap('on ', $node->typeCondition),
|
$this->wrap('on ', $node->typeCondition),
|
||||||
@ -94,46 +95,46 @@ class Printer
|
|||||||
$node->selectionSet
|
$node->selectionSet
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::FRAGMENT_DEFINITION => function(FragmentDefinition $node) {
|
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinition $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
|
||||||
Node::INT => function(IntValue $node) {return $node->value;},
|
NodeType::INT => function(IntValue $node) {return $node->value;},
|
||||||
Node::FLOAT => function(FloatValue $node) {return $node->value;},
|
NodeType::FLOAT => function(FloatValue $node) {return $node->value;},
|
||||||
Node::STRING => function(StringValue $node) {return json_encode($node->value);},
|
NodeType::STRING => function(StringValue $node) {return json_encode($node->value);},
|
||||||
Node::BOOLEAN => function(BooleanValue $node) {return $node->value ? 'true' : 'false';},
|
NodeType::BOOLEAN => function(BooleanValue $node) {return $node->value ? 'true' : 'false';},
|
||||||
Node::ENUM => function(EnumValue $node) {return $node->value;},
|
NodeType::ENUM => function(EnumValue $node) {return $node->value;},
|
||||||
Node::LST => function(ListValue $node) {return '[' . $this->join($node->values, ', ') . ']';},
|
NodeType::LST => function(ListValue $node) {return '[' . $this->join($node->values, ', ') . ']';},
|
||||||
Node::OBJECT => function(ObjectValue $node) {return '{' . $this->join($node->fields, ', ') . '}';},
|
NodeType::OBJECT => function(ObjectValue $node) {return '{' . $this->join($node->fields, ', ') . '}';},
|
||||||
Node::OBJECT_FIELD => function(ObjectField $node) {return $node->name . ': ' . $node->value;},
|
NodeType::OBJECT_FIELD => function(ObjectField $node) {return $node->name . ': ' . $node->value;},
|
||||||
|
|
||||||
// Directive
|
// Directive
|
||||||
Node::DIRECTIVE => function(Directive $node) {
|
NodeType::DIRECTIVE => function(Directive $node) {
|
||||||
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
|
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
Node::NAMED_TYPE => function(NamedType $node) {return $node->name;},
|
NodeType::NAMED_TYPE => function(NamedType $node) {return $node->name;},
|
||||||
Node::LIST_TYPE => function(ListType $node) {return '[' . $node->type . ']';},
|
NodeType::LIST_TYPE => function(ListType $node) {return '[' . $node->type . ']';},
|
||||||
Node::NON_NULL_TYPE => function(NonNullType $node) {return $node->type . '!';},
|
NodeType::NON_NULL_TYPE => function(NonNullType $node) {return $node->type . '!';},
|
||||||
|
|
||||||
// Type System Definitions
|
// Type System Definitions
|
||||||
Node::SCHEMA_DEFINITION => function(SchemaDefinition $def) {
|
NodeType::SCHEMA_DEFINITION => function(SchemaDefinition $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)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinition $def) {return $def->operation . ': ' . $def->type;},
|
NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinition $def) {return $def->operation . ': ' . $def->type;},
|
||||||
|
|
||||||
Node::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinition $def) {
|
NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinition $def) {
|
||||||
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
|
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
|
||||||
},
|
},
|
||||||
Node::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinition $def) {
|
NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'type',
|
'type',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -142,20 +143,20 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::FIELD_DEFINITION => function(FieldDefinition $def) {
|
NodeType::FIELD_DEFINITION => function(FieldDefinition $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, ' '));
|
||||||
},
|
},
|
||||||
Node::INPUT_VALUE_DEFINITION => function(InputValueDefinition $def) {
|
NodeType::INPUT_VALUE_DEFINITION => function(InputValueDefinition $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, ' ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinition $def) {
|
NodeType::INTERFACE_TYPE_DEFINITION => function(InterfaceTypeDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'interface',
|
'interface',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -163,7 +164,7 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::UNION_TYPE_DEFINITION => function(UnionTypeDefinition $def) {
|
NodeType::UNION_TYPE_DEFINITION => function(UnionTypeDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'union',
|
'union',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -171,7 +172,7 @@ class Printer
|
|||||||
'= ' . $this->join($def->types, ' | ')
|
'= ' . $this->join($def->types, ' | ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::ENUM_TYPE_DEFINITION => function(EnumTypeDefinition $def) {
|
NodeType::ENUM_TYPE_DEFINITION => function(EnumTypeDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'enum',
|
'enum',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -179,13 +180,13 @@ class Printer
|
|||||||
$this->block($def->values)
|
$this->block($def->values)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::ENUM_VALUE_DEFINITION => function(EnumValueDefinition $def) {
|
NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
$def->name,
|
$def->name,
|
||||||
$this->join($def->directives, ' ')
|
$this->join($def->directives, ' ')
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinition $def) {
|
NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinition $def) {
|
||||||
return $this->join([
|
return $this->join([
|
||||||
'input',
|
'input',
|
||||||
$def->name,
|
$def->name,
|
||||||
@ -193,10 +194,10 @@ class Printer
|
|||||||
$this->block($def->fields)
|
$this->block($def->fields)
|
||||||
], ' ');
|
], ' ');
|
||||||
},
|
},
|
||||||
Node::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinition $def) {
|
NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinition $def) {
|
||||||
return "extend {$def->definition}";
|
return "extend {$def->definition}";
|
||||||
},
|
},
|
||||||
Node::DIRECTIVE_DEFINITION => function(DirectiveDefinition $def) {
|
NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinition $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,6 +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\Utils\TypeInfo;
|
use GraphQL\Utils\TypeInfo;
|
||||||
|
|
||||||
class VisitorOperation
|
class VisitorOperation
|
||||||
@ -48,44 +49,44 @@ class Visitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static $visitorKeys = [
|
public static $visitorKeys = [
|
||||||
Node::NAME => [],
|
NodeType::NAME => [],
|
||||||
Node::DOCUMENT => ['definitions'],
|
NodeType::DOCUMENT => ['definitions'],
|
||||||
Node::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
NodeType::OPERATION_DEFINITION => ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
||||||
Node::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'],
|
NodeType::VARIABLE_DEFINITION => ['variable', 'type', 'defaultValue'],
|
||||||
Node::VARIABLE => ['name'],
|
NodeType::VARIABLE => ['name'],
|
||||||
Node::SELECTION_SET => ['selections'],
|
NodeType::SELECTION_SET => ['selections'],
|
||||||
Node::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
NodeType::FIELD => ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
||||||
Node::ARGUMENT => ['name', 'value'],
|
NodeType::ARGUMENT => ['name', 'value'],
|
||||||
Node::FRAGMENT_SPREAD => ['name', 'directives'],
|
NodeType::FRAGMENT_SPREAD => ['name', 'directives'],
|
||||||
Node::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'],
|
NodeType::INLINE_FRAGMENT => ['typeCondition', 'directives', 'selectionSet'],
|
||||||
Node::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'],
|
NodeType::FRAGMENT_DEFINITION => ['name', 'typeCondition', 'directives', 'selectionSet'],
|
||||||
|
|
||||||
Node::INT => [],
|
NodeType::INT => [],
|
||||||
Node::FLOAT => [],
|
NodeType::FLOAT => [],
|
||||||
Node::STRING => [],
|
NodeType::STRING => [],
|
||||||
Node::BOOLEAN => [],
|
NodeType::BOOLEAN => [],
|
||||||
Node::ENUM => [],
|
NodeType::ENUM => [],
|
||||||
Node::LST => ['values'],
|
NodeType::LST => ['values'],
|
||||||
Node::OBJECT => ['fields'],
|
NodeType::OBJECT => ['fields'],
|
||||||
Node::OBJECT_FIELD => ['name', 'value'],
|
NodeType::OBJECT_FIELD => ['name', 'value'],
|
||||||
Node::DIRECTIVE => ['name', 'arguments'],
|
NodeType::DIRECTIVE => ['name', 'arguments'],
|
||||||
Node::NAMED_TYPE => ['name'],
|
NodeType::NAMED_TYPE => ['name'],
|
||||||
Node::LIST_TYPE => ['type'],
|
NodeType::LIST_TYPE => ['type'],
|
||||||
Node::NON_NULL_TYPE => ['type'],
|
NodeType::NON_NULL_TYPE => ['type'],
|
||||||
|
|
||||||
Node::SCHEMA_DEFINITION => ['directives', 'operationTypes'],
|
NodeType::SCHEMA_DEFINITION => ['directives', 'operationTypes'],
|
||||||
Node::OPERATION_TYPE_DEFINITION => ['type'],
|
NodeType::OPERATION_TYPE_DEFINITION => ['type'],
|
||||||
Node::SCALAR_TYPE_DEFINITION => ['name', 'directives'],
|
NodeType::SCALAR_TYPE_DEFINITION => ['name', 'directives'],
|
||||||
Node::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'],
|
NodeType::OBJECT_TYPE_DEFINITION => ['name', 'interfaces', 'directives', 'fields'],
|
||||||
Node::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'],
|
NodeType::FIELD_DEFINITION => ['name', 'arguments', 'type', 'directives'],
|
||||||
Node::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'],
|
NodeType::INPUT_VALUE_DEFINITION => ['name', 'type', 'defaultValue', 'directives'],
|
||||||
Node::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
NodeType::INTERFACE_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
||||||
Node::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ],
|
NodeType::UNION_TYPE_DEFINITION => [ 'name', 'directives', 'types' ],
|
||||||
Node::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ],
|
NodeType::ENUM_TYPE_DEFINITION => [ 'name', 'directives', 'values' ],
|
||||||
Node::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ],
|
NodeType::ENUM_VALUE_DEFINITION => [ 'name', 'directives' ],
|
||||||
Node::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
NodeType::INPUT_OBJECT_TYPE_DEFINITION => [ 'name', 'directives', 'fields' ],
|
||||||
Node::TYPE_EXTENSION_DEFINITION => [ 'definition' ],
|
NodeType::TYPE_EXTENSION_DEFINITION => [ 'definition' ],
|
||||||
Node::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ]
|
NodeType::DIRECTIVE_DEFINITION => [ 'name', 'arguments', 'locations' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
namespace GraphQL\Tests\Language;
|
namespace GraphQL\Tests\Language;
|
||||||
|
|
||||||
use GraphQL\Language\AST\Argument;
|
use GraphQL\Language\AST\Argument;
|
||||||
use GraphQL\Language\AST\Document;
|
|
||||||
use GraphQL\Language\AST\Field;
|
use GraphQL\Language\AST\Field;
|
||||||
use GraphQL\Language\AST\IntValue;
|
|
||||||
use GraphQL\Language\AST\Location;
|
|
||||||
use GraphQL\Language\AST\Name;
|
use GraphQL\Language\AST\Name;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\OperationDefinition;
|
use GraphQL\Language\AST\NodeType;
|
||||||
use GraphQL\Language\AST\SelectionSet;
|
use GraphQL\Language\AST\SelectionSet;
|
||||||
use GraphQL\Language\AST\StringValue;
|
use GraphQL\Language\AST\StringValue;
|
||||||
use GraphQL\Language\Parser;
|
use GraphQL\Language\Parser;
|
||||||
@ -270,39 +267,39 @@ fragment $fragmentName on Type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'loc' => $loc(0, 41),
|
'loc' => $loc(0, 41),
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OPERATION_DEFINITION,
|
'kind' => NodeType::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' => Node::SELECTION_SET,
|
'kind' => NodeType::SELECTION_SET,
|
||||||
'loc' => $loc(0, 40),
|
'loc' => $loc(0, 40),
|
||||||
'selections' => [
|
'selections' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::FIELD,
|
'kind' => NodeType::FIELD,
|
||||||
'loc' => $loc(4, 38),
|
'loc' => $loc(4, 38),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => $loc(4, 8),
|
'loc' => $loc(4, 8),
|
||||||
'value' => 'node'
|
'value' => 'node'
|
||||||
],
|
],
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::ARGUMENT,
|
'kind' => NodeType::ARGUMENT,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => $loc(9, 11),
|
'loc' => $loc(9, 11),
|
||||||
'value' => 'id'
|
'value' => 'id'
|
||||||
],
|
],
|
||||||
'value' => [
|
'value' => [
|
||||||
'kind' => Node::INT,
|
'kind' => NodeType::INT,
|
||||||
'loc' => $loc(13, 14),
|
'loc' => $loc(13, 14),
|
||||||
'value' => '4'
|
'value' => '4'
|
||||||
],
|
],
|
||||||
@ -311,15 +308,15 @@ fragment $fragmentName on Type {
|
|||||||
],
|
],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'selectionSet' => [
|
'selectionSet' => [
|
||||||
'kind' => Node::SELECTION_SET,
|
'kind' => NodeType::SELECTION_SET,
|
||||||
'loc' => $loc(16, 38),
|
'loc' => $loc(16, 38),
|
||||||
'selections' => [
|
'selections' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::FIELD,
|
'kind' => NodeType::FIELD,
|
||||||
'loc' => $loc(22, 24),
|
'loc' => $loc(22, 24),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => $loc(22, 24),
|
'loc' => $loc(22, 24),
|
||||||
'value' => 'id'
|
'value' => 'id'
|
||||||
],
|
],
|
||||||
@ -328,11 +325,11 @@ fragment $fragmentName on Type {
|
|||||||
'selectionSet' => null
|
'selectionSet' => null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'kind' => Node::FIELD,
|
'kind' => NodeType::FIELD,
|
||||||
'loc' => $loc(30, 34),
|
'loc' => $loc(30, 34),
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => $loc(30, 34),
|
'loc' => $loc(30, 34),
|
||||||
'value' => 'name'
|
'value' => 'name'
|
||||||
],
|
],
|
||||||
@ -402,16 +399,16 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesListValues()
|
public function testParsesListValues()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::LST,
|
'kind' => NodeType::LST,
|
||||||
'loc' => ['start' => 0, 'end' => 11],
|
'loc' => ['start' => 0, 'end' => 11],
|
||||||
'values' => [
|
'values' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::INT,
|
'kind' => NodeType::INT,
|
||||||
'loc' => ['start' => 1, 'end' => 4],
|
'loc' => ['start' => 1, 'end' => 4],
|
||||||
'value' => '123'
|
'value' => '123'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'kind' => Node::STRING,
|
'kind' => NodeType::STRING,
|
||||||
'loc' => ['start' => 5, 'end' => 10],
|
'loc' => ['start' => 5, 'end' => 10],
|
||||||
'value' => 'abc'
|
'value' => 'abc'
|
||||||
]
|
]
|
||||||
@ -427,10 +424,10 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesWellKnownTypes()
|
public function testParsesWellKnownTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'String'
|
'value' => 'String'
|
||||||
]
|
]
|
||||||
@ -443,10 +440,10 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesCustomTypes()
|
public function testParsesCustomTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -459,13 +456,13 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesListTypes()
|
public function testParsesListTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::LIST_TYPE,
|
'kind' => NodeType::LIST_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 8],
|
'loc' => ['start' => 0, 'end' => 8],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -479,13 +476,13 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesNonNullTypes()
|
public function testParsesNonNullTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::NON_NULL_TYPE,
|
'kind' => NodeType::NON_NULL_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 7],
|
'loc' => ['start' => 0, 'end' => 7],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => ['start' => 0, 'end' => 6],
|
'loc' => ['start' => 0, 'end' => 6],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
@ -499,16 +496,16 @@ fragment $fragmentName on Type {
|
|||||||
public function testParsesNestedTypes()
|
public function testParsesNestedTypes()
|
||||||
{
|
{
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'kind' => Node::LIST_TYPE,
|
'kind' => NodeType::LIST_TYPE,
|
||||||
'loc' => ['start' => 0, 'end' => 9],
|
'loc' => ['start' => 0, 'end' => 9],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => Node::NON_NULL_TYPE,
|
'kind' => NodeType::NON_NULL_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 8],
|
'loc' => ['start' => 1, 'end' => 8],
|
||||||
'type' => [
|
'type' => [
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'name' => [
|
'name' => [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'loc' => ['start' => 1, 'end' => 7],
|
'loc' => ['start' => 1, 'end' => 7],
|
||||||
'value' => 'MyType'
|
'value' => 'MyType'
|
||||||
]
|
]
|
||||||
|
@ -14,6 +14,7 @@ use GraphQL\Language\AST\Location;
|
|||||||
use GraphQL\Language\AST\Name;
|
use GraphQL\Language\AST\Name;
|
||||||
use GraphQL\Language\AST\NamedType;
|
use GraphQL\Language\AST\NamedType;
|
||||||
use GraphQL\Language\AST\Node;
|
use GraphQL\Language\AST\Node;
|
||||||
|
use GraphQL\Language\AST\NodeType;
|
||||||
use GraphQL\Language\AST\NonNullType;
|
use GraphQL\Language\AST\NonNullType;
|
||||||
use GraphQL\Language\AST\ObjectTypeDefinition;
|
use GraphQL\Language\AST\ObjectTypeDefinition;
|
||||||
use GraphQL\Language\AST\ScalarTypeDefinition;
|
use GraphQL\Language\AST\ScalarTypeDefinition;
|
||||||
@ -39,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -76,12 +77,12 @@ extend type Hello {
|
|||||||
return TestUtils::locArray($start, $end);
|
return TestUtils::locArray($start, $end);
|
||||||
};
|
};
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::TYPE_EXTENSION_DEFINITION,
|
'kind' => NodeType::TYPE_EXTENSION_DEFINITION,
|
||||||
'definition' => [
|
'definition' => [
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(13, 18)),
|
'name' => $this->nameNode('Hello', $loc(13, 18)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -117,10 +118,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6,11)),
|
'name' => $this->nameNode('Hello', $loc(6,11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -128,7 +129,7 @@ type Hello {
|
|||||||
$this->fieldNode(
|
$this->fieldNode(
|
||||||
$this->nameNode('world', $loc(16, 21)),
|
$this->nameNode('world', $loc(16, 21)),
|
||||||
[
|
[
|
||||||
'kind' => Node::NON_NULL_TYPE,
|
'kind' => NodeType::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)
|
||||||
],
|
],
|
||||||
@ -154,10 +155,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::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))
|
||||||
@ -183,10 +184,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::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)),
|
||||||
@ -213,10 +214,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::ENUM_TYPE_DEFINITION,
|
'kind' => NodeType::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))],
|
||||||
@ -239,10 +240,10 @@ type Hello {
|
|||||||
$doc = Parser::parse($body);
|
$doc = Parser::parse($body);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'kind' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::ENUM_TYPE_DEFINITION,
|
'kind' => NodeType::ENUM_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
'name' => $this->nameNode('Hello', $loc(5, 10)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'values' => [
|
'values' => [
|
||||||
@ -271,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::INTERFACE_TYPE_DEFINITION,
|
'kind' => NodeType::INTERFACE_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(11, 16)),
|
'name' => $this->nameNode('Hello', $loc(11, 16)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -305,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -349,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -364,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' => Node::BOOLEAN, 'value' => true, 'loc' => $loc(38, 42)],
|
['kind' => NodeType::BOOLEAN, 'value' => true, 'loc' => $loc(38, 42)],
|
||||||
$loc(22, 42)
|
$loc(22, 42)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -392,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -406,7 +407,7 @@ type Hello {
|
|||||||
[
|
[
|
||||||
$this->inputValueNode(
|
$this->inputValueNode(
|
||||||
$this->nameNode('things', $loc(22,28)),
|
$this->nameNode('things', $loc(22,28)),
|
||||||
['kind' => Node::LIST_TYPE, 'type' => $this->typeNode('String', $loc(31, 37)), 'loc' => $loc(30, 38)],
|
['kind' => NodeType::LIST_TYPE, 'type' => $this->typeNode('String', $loc(31, 37)), 'loc' => $loc(30, 38)],
|
||||||
null,
|
null,
|
||||||
$loc(22, 38)
|
$loc(22, 38)
|
||||||
)
|
)
|
||||||
@ -436,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'interfaces' => [],
|
'interfaces' => [],
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
@ -482,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::UNION_TYPE_DEFINITION,
|
'kind' => NodeType::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))],
|
||||||
@ -508,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::UNION_TYPE_DEFINITION,
|
'kind' => NodeType::UNION_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
'name' => $this->nameNode('Hello', $loc(6, 11)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'types' => [
|
'types' => [
|
||||||
@ -535,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::SCALAR_TYPE_DEFINITION,
|
'kind' => NodeType::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)
|
||||||
@ -562,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' => Node::DOCUMENT,
|
'kind' => NodeType::DOCUMENT,
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
[
|
[
|
||||||
'kind' => Node::INPUT_OBJECT_TYPE_DEFINITION,
|
'kind' => NodeType::INPUT_OBJECT_TYPE_DEFINITION,
|
||||||
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
'name' => $this->nameNode('Hello', $loc(7, 12)),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -600,8 +601,8 @@ input Hello {
|
|||||||
private function typeNode($name, $loc)
|
private function typeNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => Node::NAMED_TYPE,
|
'kind' => NodeType::NAMED_TYPE,
|
||||||
'name' => ['kind' => Node::NAME, 'value' => $name, 'loc' => $loc],
|
'name' => ['kind' => NodeType::NAME, 'value' => $name, 'loc' => $loc],
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -609,7 +610,7 @@ input Hello {
|
|||||||
private function nameNode($name, $loc)
|
private function nameNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => Node::NAME,
|
'kind' => NodeType::NAME,
|
||||||
'value' => $name,
|
'value' => $name,
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
];
|
];
|
||||||
@ -623,7 +624,7 @@ input Hello {
|
|||||||
private function fieldNodeWithArgs($name, $type, $args, $loc)
|
private function fieldNodeWithArgs($name, $type, $args, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => Node::FIELD_DEFINITION,
|
'kind' => NodeType::FIELD_DEFINITION,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'arguments' => $args,
|
'arguments' => $args,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
@ -635,7 +636,7 @@ input Hello {
|
|||||||
private function enumValueNode($name, $loc)
|
private function enumValueNode($name, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => Node::ENUM_VALUE_DEFINITION,
|
'kind' => NodeType::ENUM_VALUE_DEFINITION,
|
||||||
'name' => $this->nameNode($name, $loc),
|
'name' => $this->nameNode($name, $loc),
|
||||||
'directives' => [],
|
'directives' => [],
|
||||||
'loc' => $loc
|
'loc' => $loc
|
||||||
@ -645,7 +646,7 @@ input Hello {
|
|||||||
private function inputValueNode($name, $type, $defaultValue, $loc)
|
private function inputValueNode($name, $type, $defaultValue, $loc)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'kind' => Node::INPUT_VALUE_DEFINITION,
|
'kind' => NodeType::INPUT_VALUE_DEFINITION,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'defaultValue' => $defaultValue,
|
'defaultValue' => $defaultValue,
|
||||||
|
Loading…
Reference in New Issue
Block a user