mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-24 22:06:04 +03:00
Renamed AST nodes to *Node
to disambiguate types
This commit is contained in:
parent
5ce9a7009a
commit
8d696edee5
@ -28,7 +28,7 @@ Description of method arguments:
|
||||
Argument | Type | Notes
|
||||
------------ | -------- | -----
|
||||
schema | `GraphQL\Schema` | **Required.** Instance of your application [Schema](type-system/schema/)
|
||||
queryString | `string` or `GraphQL\Language\AST\Document` | **Required.** Actual GraphQL query string to be parsed, validated and executed. If you parse query elsewhere before executing - pass corresponding ast document here to avoid new parsing.
|
||||
queryString | `string` or `GraphQL\Language\AST\DocumentNode` | **Required.** Actual GraphQL query string to be parsed, validated and executed. If you parse query elsewhere before executing - pass corresponding ast document here to avoid new parsing.
|
||||
rootValue | `mixed` | Any value that represents a root of your data graph. It is passed as 1st argument to field resolvers of [Query type](type-system/schema/#query-and-mutation-types). Can be omitted or set to null if actual root values are fetched by Query type itself.
|
||||
contextValue | `mixed` | Any value that holds information shared between all field resolvers. Most often they use it to pass currently logged in user, locale details, etc.<br><br>It will be available as 3rd argument in all field resolvers. (see section on [Field Definitions](type-system/object-types/#field-configuration-options) for reference) **graphql-php** never modifies this value and passes it *as is* to all underlying resolvers.
|
||||
variableValues | `array` | Map of variable values passed along with query string. See section on [query variables on official GraphQL website](http://graphql.org/learn/queries/#variables)
|
||||
|
@ -42,7 +42,7 @@ Here is an example of simple `Email` type (using inheritance):
|
||||
namespace MyApp;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Type\Definition\ScalarType;
|
||||
use GraphQL\Utils;
|
||||
|
||||
@ -98,7 +98,7 @@ class EmailType extends ScalarType
|
||||
{
|
||||
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
|
||||
// error location in query:
|
||||
if (!$valueAST instanceof StringValue) {
|
||||
if (!$valueAST instanceof StringValueNode) {
|
||||
throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]);
|
||||
}
|
||||
if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Examples\Blog\Type\Scalar;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Examples\Blog\Type\BaseType;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Type\Definition\CustomScalarType;
|
||||
use GraphQL\Utils;
|
||||
|
||||
@ -61,7 +61,7 @@ class EmailType extends BaseType
|
||||
{
|
||||
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
|
||||
// error location in query:
|
||||
if (!$valueAST instanceof StringValue) {
|
||||
if (!$valueAST instanceof StringValueNode) {
|
||||
throw new Error('Query error: Can only parse strings got: ' . $valueAST->kind, [$valueAST]);
|
||||
}
|
||||
if (!filter_var($valueAST->value, FILTER_VALIDATE_EMAIL)) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Examples\Blog\Type\Scalar;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Type\Definition\ScalarType;
|
||||
use GraphQL\Utils;
|
||||
|
||||
@ -52,7 +52,7 @@ class UrlType extends ScalarType
|
||||
{
|
||||
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
|
||||
// error location in query:
|
||||
if (!($ast instanceof StringValue)) {
|
||||
if (!($ast instanceof StringValueNode)) {
|
||||
throw new Error('Query error: Can only parse strings got: ' . $ast->kind, [$ast]);
|
||||
}
|
||||
if (!is_string($ast->value) || !filter_var($ast->value, FILTER_VALIDATE_URL)) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace GraphQL\Executor;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Schema;
|
||||
|
||||
/**
|
||||
@ -19,7 +19,7 @@ class ExecutionContext
|
||||
public $schema;
|
||||
|
||||
/**
|
||||
* @var array<string, FragmentDefinition>
|
||||
* @var array<string, FragmentDefinitionNode>
|
||||
*/
|
||||
public $fragments;
|
||||
|
||||
@ -34,7 +34,7 @@ class ExecutionContext
|
||||
public $contextValue;
|
||||
|
||||
/**
|
||||
* @var OperationDefinition
|
||||
* @var OperationDefinitionNode
|
||||
*/
|
||||
public $operation;
|
||||
|
||||
|
@ -3,13 +3,13 @@ namespace GraphQL\Executor;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
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\OperationDefinition;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Schema;
|
||||
use GraphQL\Type\Definition\AbstractType;
|
||||
use GraphQL\Type\Definition\Directive;
|
||||
@ -62,14 +62,14 @@ class Executor
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @param Document $ast
|
||||
* @param DocumentNode $ast
|
||||
* @param $rootValue
|
||||
* @param $contextValue
|
||||
* @param array|\ArrayAccess $variableValues
|
||||
* @param null $operationName
|
||||
* @return ExecutionResult
|
||||
*/
|
||||
public static function execute(Schema $schema, Document $ast, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null)
|
||||
public static function execute(Schema $schema, DocumentNode $ast, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null)
|
||||
{
|
||||
if (!self::$UNDEFINED) {
|
||||
self::$UNDEFINED = new \stdClass();
|
||||
@ -106,7 +106,7 @@ class Executor
|
||||
*/
|
||||
private static function buildExecutionContext(
|
||||
Schema $schema,
|
||||
Document $documentAst,
|
||||
DocumentNode $documentAst,
|
||||
$rootValue,
|
||||
$contextValue,
|
||||
$rawVariableValues,
|
||||
@ -162,7 +162,7 @@ class Executor
|
||||
/**
|
||||
* Implements the "Evaluating operations" section of the spec.
|
||||
*/
|
||||
private static function executeOperation(ExecutionContext $exeContext, OperationDefinition $operation, $rootValue)
|
||||
private static function executeOperation(ExecutionContext $exeContext, OperationDefinitionNode $operation, $rootValue)
|
||||
{
|
||||
$type = self::getOperationRootType($exeContext->schema, $operation);
|
||||
$fields = self::collectFields($exeContext, $type, $operation->selectionSet, new \ArrayObject(), new \ArrayObject());
|
||||
@ -180,11 +180,11 @@ class Executor
|
||||
* Extracts the root type of the operation from the schema.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param OperationDefinition $operation
|
||||
* @param OperationDefinitionNode $operation
|
||||
* @return ObjectType
|
||||
* @throws Error
|
||||
*/
|
||||
private static function getOperationRootType(Schema $schema, OperationDefinition $operation)
|
||||
private static function getOperationRootType(Schema $schema, OperationDefinitionNode $operation)
|
||||
{
|
||||
switch ($operation->operation) {
|
||||
case 'query':
|
||||
@ -264,7 +264,7 @@ class Executor
|
||||
private static function collectFields(
|
||||
ExecutionContext $exeContext,
|
||||
ObjectType $runtimeType,
|
||||
SelectionSet $selectionSet,
|
||||
SelectionSetNode $selectionSet,
|
||||
$fields,
|
||||
$visitedFragmentNames
|
||||
)
|
||||
@ -302,7 +302,7 @@ class Executor
|
||||
}
|
||||
$visitedFragmentNames[$fragName] = true;
|
||||
|
||||
/** @var FragmentDefinition|null $fragment */
|
||||
/** @var FragmentDefinitionNode|null $fragment */
|
||||
$fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null;
|
||||
if (!$fragment || !self::doesFragmentConditionMatch($exeContext, $fragment, $runtimeType)) {
|
||||
continue;
|
||||
@ -329,9 +329,9 @@ class Executor
|
||||
$skipDirective = Directive::skipDirective();
|
||||
$includeDirective = Directive::includeDirective();
|
||||
|
||||
/** @var \GraphQL\Language\AST\Directive $skipAST */
|
||||
/** @var \GraphQL\Language\AST\DirectiveNode $skipAST */
|
||||
$skipAST = $directives
|
||||
? Utils::find($directives, function(\GraphQL\Language\AST\Directive $directive) use ($skipDirective) {
|
||||
? Utils::find($directives, function(\GraphQL\Language\AST\DirectiveNode $directive) use ($skipDirective) {
|
||||
return $directive->name->value === $skipDirective->name;
|
||||
})
|
||||
: null;
|
||||
@ -343,9 +343,9 @@ class Executor
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \GraphQL\Language\AST\Directive $includeAST */
|
||||
/** @var \GraphQL\Language\AST\DirectiveNode $includeAST */
|
||||
$includeAST = $directives
|
||||
? Utils::find($directives, function(\GraphQL\Language\AST\Directive $directive) use ($includeDirective) {
|
||||
? Utils::find($directives, function(\GraphQL\Language\AST\DirectiveNode $directive) use ($includeDirective) {
|
||||
return $directive->name->value === $includeDirective->name;
|
||||
})
|
||||
: null;
|
||||
@ -363,7 +363,7 @@ class Executor
|
||||
/**
|
||||
* Determines if a fragment is applicable to the given type.
|
||||
*/
|
||||
private static function doesFragmentConditionMatch(ExecutionContext $exeContext,/* FragmentDefinition | InlineFragment*/ $fragment, ObjectType $type)
|
||||
private static function doesFragmentConditionMatch(ExecutionContext $exeContext,/* FragmentDefinitionNode | InlineFragmentNode*/ $fragment, ObjectType $type)
|
||||
{
|
||||
$typeConditionAST = $fragment->typeCondition;
|
||||
|
||||
@ -384,7 +384,7 @@ class Executor
|
||||
/**
|
||||
* Implements the logic to compute the key of a given fields entry
|
||||
*/
|
||||
private static function getFieldEntryKey(Field $node)
|
||||
private static function getFieldEntryKey(FieldNode $node)
|
||||
{
|
||||
return $node->alias ? $node->alias->value : $node->name->value;
|
||||
}
|
||||
@ -468,7 +468,7 @@ class Executor
|
||||
*
|
||||
* @param ExecutionContext $exeContext
|
||||
* @param FieldDefinition $fieldDef
|
||||
* @param Field $fieldAST
|
||||
* @param FieldNode $fieldAST
|
||||
* @param callable $resolveFn
|
||||
* @param mixed $source
|
||||
* @param mixed $context
|
||||
@ -605,7 +605,7 @@ class Executor
|
||||
*
|
||||
* @param ExecutionContext $exeContext
|
||||
* @param Type $returnType
|
||||
* @param Field[] $fieldASTs
|
||||
* @param FieldNode[] $fieldASTs
|
||||
* @param ResolveInfo $info
|
||||
* @param array $path
|
||||
* @param $result
|
||||
|
@ -4,12 +4,12 @@ namespace GraphQL\Executor;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\NullValue;
|
||||
use GraphQL\Language\AST\Value;
|
||||
use GraphQL\Language\AST\Variable;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ValueNode;
|
||||
use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Schema;
|
||||
use GraphQL\Type\Definition\Directive;
|
||||
@ -32,7 +32,7 @@ class Values
|
||||
* to match the variable definitions, a Error will be thrown.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param VariableDefinition[] $definitionASTs
|
||||
* @param VariableDefinitionNode[] $definitionASTs
|
||||
* @param array $inputs
|
||||
* @return array
|
||||
* @throws Error
|
||||
@ -89,7 +89,7 @@ class Values
|
||||
* definitions and list of argument AST nodes.
|
||||
*
|
||||
* @param FieldDefinition|Directive $def
|
||||
* @param Field|\GraphQL\Language\AST\Directive $node
|
||||
* @param FieldNode|\GraphQL\Language\AST\DirectiveNode $node
|
||||
* @param $variableValues
|
||||
* @return array
|
||||
* @throws Error
|
||||
@ -106,8 +106,8 @@ class Values
|
||||
$coercedValues = [];
|
||||
$undefined = Utils::undefined();
|
||||
|
||||
/** @var Argument[] $argASTMap */
|
||||
$argASTMap = $argASTs ? Utils::keyMap($argASTs, function (Argument $arg) {
|
||||
/** @var ArgumentNode[] $argASTMap */
|
||||
$argASTMap = $argASTs ? Utils::keyMap($argASTs, function (ArgumentNode $arg) {
|
||||
return $arg->name->value;
|
||||
}) : [];
|
||||
|
||||
@ -126,7 +126,7 @@ class Values
|
||||
[$node]
|
||||
);
|
||||
}
|
||||
} else if ($argumentAST->value instanceof Variable) {
|
||||
} else if ($argumentAST->value instanceof VariableNode) {
|
||||
$variableName = $argumentAST->value->name->value;
|
||||
|
||||
if ($variableValues && array_key_exists($variableName, $variableValues)) {
|
||||
|
@ -4,7 +4,7 @@ namespace GraphQL;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Executor\ExecutionResult;
|
||||
use GraphQL\Executor\Executor;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\DocumentNode;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Source;
|
||||
use GraphQL\Type\Definition\Directive;
|
||||
@ -37,7 +37,7 @@ class GraphQL
|
||||
public static function executeAndReturnResult(Schema $schema, $requestString, $rootValue = null, $contextValue = null, $variableValues = null, $operationName = null)
|
||||
{
|
||||
try {
|
||||
if ($requestString instanceof Document) {
|
||||
if ($requestString instanceof DocumentNode) {
|
||||
$documentAST = $requestString;
|
||||
} else {
|
||||
$source = new Source($requestString ?: '', 'GraphQL request');
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Argument extends Node
|
||||
class ArgumentNode extends Node
|
||||
{
|
||||
public $kind = NodeType::ARGUMENT;
|
||||
|
||||
/**
|
||||
* @var Value
|
||||
* @var ValueNode
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
|
||||
class BooleanValue extends Node implements Value
|
||||
class BooleanValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::BOOLEAN;
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface Definition
|
||||
{
|
||||
/**
|
||||
* export type Definition = OperationDefinition
|
||||
* | FragmentDefinition
|
||||
* | TypeSystemDefinition // experimental non-spec addition.
|
||||
*/
|
||||
}
|
11
src/Language/AST/DefinitionNode.php
Normal file
11
src/Language/AST/DefinitionNode.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface DefinitionNode
|
||||
{
|
||||
/**
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
* | TypeSystemDefinitionNode // experimental non-spec addition.
|
||||
*/
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class DirectiveDefinition extends Node implements TypeSystemDefinition
|
||||
class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,17 +9,17 @@ class DirectiveDefinition extends Node implements TypeSystemDefinition
|
||||
public $kind = NodeType::DIRECTIVE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Argument[]
|
||||
* @var ArgumentNode[]
|
||||
*/
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var Name[]
|
||||
* @var NameNode[]
|
||||
*/
|
||||
public $locations;
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Directive extends Node
|
||||
class DirectiveNode extends Node
|
||||
{
|
||||
public $kind = NodeType::DIRECTIVE;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Argument[]
|
||||
* @var ArgumentNode[]
|
||||
*/
|
||||
public $arguments;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Document extends Node
|
||||
class DocumentNode extends Node
|
||||
{
|
||||
public $kind = NodeType::DOCUMENT;
|
||||
|
||||
/**
|
||||
* @var Definition[]
|
||||
* @var DefinitionNode[]
|
||||
*/
|
||||
public $definitions;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumTypeDefinition extends Node implements TypeDefinition
|
||||
class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,17 +9,17 @@ class EnumTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::ENUM_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var EnumValueDefinition[]
|
||||
* @var EnumValueDefinitionNode[]
|
||||
*/
|
||||
public $values;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumValueDefinition extends Node
|
||||
class EnumValueDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,12 +9,12 @@ class EnumValueDefinition extends Node
|
||||
public $kind = NodeType::ENUM_VALUE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class EnumValue extends Node implements Value
|
||||
class EnumValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::ENUM;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FieldDefinition extends Node
|
||||
class FieldDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,22 +9,22 @@ class FieldDefinition extends Node
|
||||
public $kind = NodeType::FIELD_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var InputValueDefinition[]
|
||||
* @var InputValueDefinitionNode[]
|
||||
*/
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
* @var TypeNode
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
}
|
@ -1,32 +1,32 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Field extends Node implements Selection
|
||||
class FieldNode extends Node implements SelectionNode
|
||||
{
|
||||
public $kind = NodeType::FIELD;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Name|null
|
||||
* @var NameNode|null
|
||||
*/
|
||||
public $alias;
|
||||
|
||||
/**
|
||||
* @var array<Argument>|null
|
||||
* @var array<ArgumentNode>|null
|
||||
*/
|
||||
public $arguments;
|
||||
|
||||
/**
|
||||
* @var array<Directive>|null
|
||||
* @var array<DirectiveNode>|null
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSet|null
|
||||
* @var SelectionSetNode|null
|
||||
*/
|
||||
public $selectionSet;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FloatValue extends Node implements Value
|
||||
class FloatValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::FLOAT;
|
||||
|
@ -1,27 +1,27 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FragmentDefinition extends Node implements Definition, HasSelectionSet
|
||||
class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
{
|
||||
public $kind = NodeType::FRAGMENT_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var NamedType
|
||||
* @var NamedTypeNode
|
||||
*/
|
||||
public $typeCondition;
|
||||
|
||||
/**
|
||||
* @var array<Directive>
|
||||
* @var array<DirectiveNode>
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSet
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
public $selectionSet;
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FragmentSpread extends Node implements Selection
|
||||
class FragmentSpreadNode extends Node implements SelectionNode
|
||||
{
|
||||
public $kind = NodeType::FRAGMENT_SPREAD;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var array<Directive>
|
||||
* @var array<DirectiveNode>
|
||||
*/
|
||||
public $directives;
|
||||
}
|
@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
|
||||
interface HasSelectionSet
|
||||
{
|
||||
/**
|
||||
* export type Definition = OperationDefinition
|
||||
* | FragmentDefinition
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
*/
|
||||
}
|
||||
|
@ -1,22 +1,22 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InlineFragment extends Node implements Selection
|
||||
class InlineFragmentNode extends Node implements SelectionNode
|
||||
{
|
||||
public $kind = NodeType::INLINE_FRAGMENT;
|
||||
|
||||
/**
|
||||
* @var NamedType
|
||||
* @var NamedTypeNode
|
||||
*/
|
||||
public $typeCondition;
|
||||
|
||||
/**
|
||||
* @var array<Directive>|null
|
||||
* @var array<DirectiveNode>|null
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSet
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
public $selectionSet;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InputObjectTypeDefinition extends Node implements TypeDefinition
|
||||
class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,17 +9,17 @@ class InputObjectTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::INPUT_OBJECT_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var InputValueDefinition[]
|
||||
* @var InputValueDefinitionNode[]
|
||||
*/
|
||||
public $fields;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InputValueDefinition extends Node
|
||||
class InputValueDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,22 +9,22 @@ class InputValueDefinition extends Node
|
||||
public $kind = NodeType::INPUT_VALUE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
* @var TypeNode
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var Value
|
||||
* @var ValueNode
|
||||
*/
|
||||
public $defaultValue;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class IntValue extends Node implements Value
|
||||
class IntValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::INT;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class InterfaceTypeDefinition extends Node implements TypeDefinition
|
||||
class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,17 +9,17 @@ class InterfaceTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::INTERFACE_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var FieldDefinition[]
|
||||
* @var FieldDefinitionNode[]
|
||||
*/
|
||||
public $fields = [];
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ListType extends Node implements Type
|
||||
class ListTypeNode extends Node implements TypeNode
|
||||
{
|
||||
public $kind = NodeType::LIST_TYPE;
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ListValue extends Node implements Value
|
||||
class ListValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::LST;
|
||||
|
||||
/**
|
||||
* @var array<Value>
|
||||
* @var array<ValueNode>
|
||||
*/
|
||||
public $values;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Name extends Node implements Type
|
||||
class NameNode extends Node implements TypeNode
|
||||
{
|
||||
public $kind = NodeType::NAME;
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NamedType extends Node implements Type
|
||||
class NamedTypeNode extends Node implements TypeNode
|
||||
{
|
||||
public $kind = NodeType::NAMED_TYPE;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
}
|
@ -6,28 +6,28 @@ use GraphQL\Utils;
|
||||
abstract class Node
|
||||
{
|
||||
/**
|
||||
type Node = Name
|
||||
| Document
|
||||
| OperationDefinition
|
||||
| VariableDefinition
|
||||
| Variable
|
||||
| SelectionSet
|
||||
| Field
|
||||
| Argument
|
||||
| FragmentSpread
|
||||
| InlineFragment
|
||||
| FragmentDefinition
|
||||
| IntValue
|
||||
| FloatValue
|
||||
| StringValue
|
||||
| BooleanValue
|
||||
| EnumValue
|
||||
| ListValue
|
||||
| ObjectValue
|
||||
| ObjectField
|
||||
| Directive
|
||||
| ListType
|
||||
| NonNullType
|
||||
type Node = NameNode
|
||||
| DocumentNode
|
||||
| OperationDefinitionNode
|
||||
| VariableDefinitionNode
|
||||
| VariableNode
|
||||
| SelectionSetNode
|
||||
| FieldNode
|
||||
| ArgumentNode
|
||||
| FragmentSpreadNode
|
||||
| InlineFragmentNode
|
||||
| FragmentDefinitionNode
|
||||
| IntValueNode
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
| BooleanValueNode
|
||||
| EnumValueNode
|
||||
| ListValueNode
|
||||
| ObjectValueNode
|
||||
| ObjectFieldNode
|
||||
| DirectiveNode
|
||||
| ListTypeNode
|
||||
| NonNullTypeNode
|
||||
*/
|
||||
|
||||
public $kind;
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NonNullType extends Node implements Type
|
||||
class NonNullTypeNode extends Node implements TypeNode
|
||||
{
|
||||
public $kind = NodeType::NON_NULL_TYPE;
|
||||
|
||||
/**
|
||||
* @var Name | ListType
|
||||
* @var NameNode | ListTypeNode
|
||||
*/
|
||||
public $type;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class NullValue extends Node implements Value
|
||||
class NullValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::NULL;
|
||||
}
|
@ -2,17 +2,17 @@
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
|
||||
class ObjectField extends Node
|
||||
class ObjectFieldNode extends Node
|
||||
{
|
||||
public $kind = NodeType::OBJECT_FIELD;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Value
|
||||
* @var ValueNode
|
||||
*/
|
||||
public $value;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectTypeDefinition extends Node implements TypeDefinition
|
||||
class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,22 +9,22 @@ class ObjectTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::OBJECT_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var NamedType[]
|
||||
* @var NamedTypeNode[]
|
||||
*/
|
||||
public $interfaces = [];
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var FieldDefinition[]
|
||||
* @var FieldDefinitionNode[]
|
||||
*/
|
||||
public $fields;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ObjectValue extends Node implements Value
|
||||
class ObjectValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::OBJECT;
|
||||
|
||||
/**
|
||||
* @var array<ObjectField>
|
||||
* @var array<ObjectFieldNode>
|
||||
*/
|
||||
public $fields;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class OperationDefinition extends Node implements Definition, HasSelectionSet
|
||||
class OperationDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,7 +9,7 @@ class OperationDefinition extends Node implements Definition, HasSelectionSet
|
||||
public $kind = NodeType::OPERATION_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
@ -19,17 +19,17 @@ class OperationDefinition extends Node implements Definition, HasSelectionSet
|
||||
public $operation;
|
||||
|
||||
/**
|
||||
* @var array<VariableDefinition>
|
||||
* @var array<VariableDefinitionNode>
|
||||
*/
|
||||
public $variableDefinitions;
|
||||
|
||||
/**
|
||||
* @var array<Directive>
|
||||
* @var array<DirectiveNode>
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var SelectionSet
|
||||
* @var SelectionSetNode
|
||||
*/
|
||||
public $selectionSet;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class OperationTypeDefinition extends Node
|
||||
class OperationTypeDefinitionNode extends Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -16,7 +16,7 @@ class OperationTypeDefinition extends Node
|
||||
public $operation;
|
||||
|
||||
/**
|
||||
* @var NamedType
|
||||
* @var NamedTypeNode
|
||||
*/
|
||||
public $type;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class ScalarTypeDefinition extends Node implements TypeDefinition
|
||||
class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,12 +9,12 @@ class ScalarTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::SCALAR_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class SchemaDefinition extends Node implements TypeSystemDefinition
|
||||
class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,12 +9,12 @@ class SchemaDefinition extends Node implements TypeSystemDefinition
|
||||
public $kind = NodeType::SCHEMA_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var OperationTypeDefinition[]
|
||||
* @var OperationTypeDefinitionNode[]
|
||||
*/
|
||||
public $operationTypes;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface Selection
|
||||
{
|
||||
/**
|
||||
* export type Selection = Field | FragmentSpread | InlineFragment
|
||||
*/
|
||||
}
|
9
src/Language/AST/SelectionNode.php
Normal file
9
src/Language/AST/SelectionNode.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface SelectionNode
|
||||
{
|
||||
/**
|
||||
* export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode
|
||||
*/
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class SelectionSet extends Node
|
||||
class SelectionSetNode extends Node
|
||||
{
|
||||
public $kind = NodeType::SELECTION_SET;
|
||||
|
||||
/**
|
||||
* @var array<Selection>
|
||||
* @var array<SelectionNode>
|
||||
*/
|
||||
public $selections;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class StringValue extends Node implements Value
|
||||
class StringValueNode extends Node implements ValueNode
|
||||
{
|
||||
public $kind = NodeType::STRING;
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
|
||||
interface Type
|
||||
{
|
||||
/**
|
||||
export type Type = NamedType
|
||||
| ListType
|
||||
| NonNullType
|
||||
*/
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface TypeDefinition extends TypeSystemDefinition
|
||||
{
|
||||
/**
|
||||
export type TypeDefinition = ScalarTypeDefinition
|
||||
| ObjectTypeDefinition
|
||||
| InterfaceTypeDefinition
|
||||
| UnionTypeDefinition
|
||||
| EnumTypeDefinition
|
||||
| InputObjectTypeDefinition
|
||||
*/
|
||||
}
|
14
src/Language/AST/TypeDefinitionNode.php
Normal file
14
src/Language/AST/TypeDefinitionNode.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface TypeDefinitionNode extends TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
export type TypeDefinitionNode = ScalarTypeDefinitionNode
|
||||
| ObjectTypeDefinitionNode
|
||||
| InterfaceTypeDefinitionNode
|
||||
| UnionTypeDefinitionNode
|
||||
| EnumTypeDefinitionNode
|
||||
| InputObjectTypeDefinitionNode
|
||||
*/
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class TypeExtensionDefinition extends Node implements TypeSystemDefinition
|
||||
class TypeExtensionDefinitionNode extends Node implements TypeSystemDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,7 +9,7 @@ class TypeExtensionDefinition extends Node implements TypeSystemDefinition
|
||||
public $kind = NodeType::TYPE_EXTENSION_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var ObjectTypeDefinition
|
||||
* @var ObjectTypeDefinitionNode
|
||||
*/
|
||||
public $definition;
|
||||
}
|
13
src/Language/AST/TypeNode.php
Normal file
13
src/Language/AST/TypeNode.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
|
||||
interface TypeNode
|
||||
{
|
||||
/**
|
||||
export type TypeNode = NamedTypeNode
|
||||
| ListTypeNode
|
||||
| NonNullTypeNode
|
||||
*/
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface TypeSystemDefinition extends Definition
|
||||
{
|
||||
/**
|
||||
export type TypeSystemDefinition = SchemaDefinition
|
||||
| TypeDefinition
|
||||
| TypeExtensionDefinition
|
||||
| DirectiveDefinition
|
||||
*/
|
||||
}
|
12
src/Language/AST/TypeSystemDefinitionNode.php
Normal file
12
src/Language/AST/TypeSystemDefinitionNode.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface TypeSystemDefinitionNode extends DefinitionNode
|
||||
{
|
||||
/**
|
||||
export type TypeSystemDefinitionNode = SchemaDefinitionNode
|
||||
| TypeDefinitionNode
|
||||
| TypeExtensionDefinitionNode
|
||||
| DirectiveDefinitionNode
|
||||
*/
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class UnionTypeDefinition extends Node implements TypeDefinition
|
||||
class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -9,17 +9,17 @@ class UnionTypeDefinition extends Node implements TypeDefinition
|
||||
public $kind = NodeType::UNION_TYPE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var Directive[]
|
||||
* @var DirectiveNode[]
|
||||
*/
|
||||
public $directives;
|
||||
|
||||
/**
|
||||
* @var NamedType[]
|
||||
* @var NamedTypeNode[]
|
||||
*/
|
||||
public $types = [];
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
export type Value = Variable
|
||||
| IntValue
|
||||
| FloatValue
|
||||
| StringValue
|
||||
| BooleanValue
|
||||
| EnumValue
|
||||
| ListValue
|
||||
| ObjectValue
|
||||
*/
|
||||
interface Value
|
||||
{
|
||||
|
||||
}
|
17
src/Language/AST/ValueNode.php
Normal file
17
src/Language/AST/ValueNode.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
/**
|
||||
export type ValueNode = VariableNode
|
||||
| IntValueNode
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
| BooleanValueNode
|
||||
| EnumValueNode
|
||||
| ListValueNode
|
||||
| ObjectValueNode
|
||||
*/
|
||||
interface ValueNode
|
||||
{
|
||||
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class VariableDefinition extends Node implements Definition
|
||||
class VariableDefinitionNode extends Node implements DefinitionNode
|
||||
{
|
||||
public $kind = NodeType::VARIABLE_DEFINITION;
|
||||
|
||||
/**
|
||||
* @var Variable
|
||||
* @var VariableNode
|
||||
*/
|
||||
public $variable;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
* @var TypeNode
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var Value|null
|
||||
* @var ValueNode|null
|
||||
*/
|
||||
public $defaultValue;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class Variable extends Node
|
||||
class VariableNode extends Node
|
||||
{
|
||||
public $kind = NodeType::VARIABLE;
|
||||
|
||||
/**
|
||||
* @var Name
|
||||
* @var NameNode
|
||||
*/
|
||||
public $name;
|
||||
}
|
@ -3,45 +3,45 @@ namespace GraphQL\Language;
|
||||
|
||||
// language/parser.js
|
||||
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\DirectiveDefinition;
|
||||
use GraphQL\Language\AST\EnumTypeDefinition;
|
||||
use GraphQL\Language\AST\EnumValueDefinition;
|
||||
use GraphQL\Language\AST\FieldDefinition;
|
||||
use GraphQL\Language\AST\InputObjectTypeDefinition;
|
||||
use GraphQL\Language\AST\InputValueDefinition;
|
||||
use GraphQL\Language\AST\InterfaceTypeDefinition;
|
||||
use GraphQL\Language\AST\ListValue;
|
||||
use GraphQL\Language\AST\BooleanValue;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\EnumValue;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FloatValue;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\ListType;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\DirectiveDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumValueDefinitionNode;
|
||||
use GraphQL\Language\AST\FieldDefinitionNode;
|
||||
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\InputValueDefinitionNode;
|
||||
use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ListValueNode;
|
||||
use GraphQL\Language\AST\BooleanValueNode;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\DocumentNode;
|
||||
use GraphQL\Language\AST\EnumValueNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\FloatValueNode;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\InlineFragmentNode;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Language\AST\ListTypeNode;
|
||||
use GraphQL\Language\AST\Location;
|
||||
use GraphQL\Language\AST\Name;
|
||||
use GraphQL\Language\AST\NamedType;
|
||||
use GraphQL\Language\AST\NonNullType;
|
||||
use GraphQL\Language\AST\NullValue;
|
||||
use GraphQL\Language\AST\ObjectField;
|
||||
use GraphQL\Language\AST\ObjectTypeDefinition;
|
||||
use GraphQL\Language\AST\ObjectValue;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationTypeDefinition;
|
||||
use GraphQL\Language\AST\ScalarTypeDefinition;
|
||||
use GraphQL\Language\AST\SchemaDefinition;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\TypeExtensionDefinition;
|
||||
use GraphQL\Language\AST\TypeSystemDefinition;
|
||||
use GraphQL\Language\AST\UnionTypeDefinition;
|
||||
use GraphQL\Language\AST\Variable;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\NameNode;
|
||||
use GraphQL\Language\AST\NamedTypeNode;
|
||||
use GraphQL\Language\AST\NonNullTypeNode;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ObjectFieldNode;
|
||||
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ObjectValueNode;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\OperationTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\SchemaDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Language\AST\TypeExtensionDefinitionNode;
|
||||
use GraphQL\Language\AST\TypeSystemDefinitionNode;
|
||||
use GraphQL\Language\AST\UnionTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Error\SyntaxError;
|
||||
|
||||
class Parser
|
||||
@ -56,7 +56,7 @@ class Parser
|
||||
*
|
||||
* @param Source|string $source
|
||||
* @param array $options
|
||||
* @return Document
|
||||
* @return DocumentNode
|
||||
*/
|
||||
public static function parse($source, array $options = [])
|
||||
{
|
||||
@ -78,7 +78,7 @@ class Parser
|
||||
*
|
||||
* @param Source|string $source
|
||||
* @param array $options
|
||||
* @return BooleanValue|EnumValue|FloatValue|IntValue|ListValue|ObjectValue|StringValue|Variable
|
||||
* @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode
|
||||
*/
|
||||
public static function parseValue($source, array $options = [])
|
||||
{
|
||||
@ -101,7 +101,7 @@ class Parser
|
||||
* Consider providing the results to the utility function: typeFromAST().
|
||||
* @param Source|string $source
|
||||
* @param array $options
|
||||
* @return ListType|Name|NonNullType
|
||||
* @return ListTypeNode|NameNode|NonNullTypeNode
|
||||
*/
|
||||
public static function parseType($source, array $options = [])
|
||||
{
|
||||
@ -277,14 +277,14 @@ class Parser
|
||||
/**
|
||||
* Converts a name lex token into a name parse node.
|
||||
*
|
||||
* @return Name
|
||||
* @return NameNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseName()
|
||||
{
|
||||
$token = $this->expect(Token::NAME);
|
||||
|
||||
return new Name([
|
||||
return new NameNode([
|
||||
'value' => $token->value,
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
@ -293,7 +293,7 @@ class Parser
|
||||
/**
|
||||
* Implements the parsing rules in the Document section.
|
||||
*
|
||||
* @return Document
|
||||
* @return DocumentNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseDocument()
|
||||
@ -306,14 +306,14 @@ class Parser
|
||||
$definitions[] = $this->parseDefinition();
|
||||
} while (!$this->skip(Token::EOF));
|
||||
|
||||
return new Document([
|
||||
return new DocumentNode([
|
||||
'definitions' => $definitions,
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OperationDefinition|FragmentDefinition|TypeSystemDefinition
|
||||
* @return OperationDefinitionNode|FragmentDefinitionNode|TypeSystemDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseDefinition()
|
||||
@ -352,14 +352,14 @@ class Parser
|
||||
// Implements the parsing rules in the Operations section.
|
||||
|
||||
/**
|
||||
* @return OperationDefinition
|
||||
* @return OperationDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseOperationDefinition()
|
||||
{
|
||||
$start = $this->lexer->token;
|
||||
if ($this->peek(Token::BRACE_L)) {
|
||||
return new OperationDefinition([
|
||||
return new OperationDefinitionNode([
|
||||
'operation' => 'query',
|
||||
'name' => null,
|
||||
'variableDefinitions' => null,
|
||||
@ -376,7 +376,7 @@ class Parser
|
||||
$name = $this->parseName();
|
||||
}
|
||||
|
||||
return new OperationDefinition([
|
||||
return new OperationDefinitionNode([
|
||||
'operation' => $operation,
|
||||
'name' => $name,
|
||||
'variableDefinitions' => $this->parseVariableDefinitions(),
|
||||
@ -404,7 +404,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<VariableDefinition>
|
||||
* @return array<VariableDefinitionNode>
|
||||
*/
|
||||
function parseVariableDefinitions()
|
||||
{
|
||||
@ -418,7 +418,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VariableDefinition
|
||||
* @return VariableDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseVariableDefinition()
|
||||
@ -429,7 +429,7 @@ class Parser
|
||||
$this->expect(Token::COLON);
|
||||
$type = $this->parseTypeReference();
|
||||
|
||||
return new VariableDefinition([
|
||||
return new VariableDefinitionNode([
|
||||
'variable' => $var,
|
||||
'type' => $type,
|
||||
'defaultValue' =>
|
||||
@ -439,7 +439,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Variable
|
||||
* @return VariableNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseVariable()
|
||||
@ -447,19 +447,19 @@ class Parser
|
||||
$start = $this->lexer->token;
|
||||
$this->expect(Token::DOLLAR);
|
||||
|
||||
return new Variable([
|
||||
return new VariableNode([
|
||||
'name' => $this->parseName(),
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectionSet
|
||||
* @return SelectionSetNode
|
||||
*/
|
||||
function parseSelectionSet()
|
||||
{
|
||||
$start = $this->lexer->token;
|
||||
return new SelectionSet([
|
||||
return new SelectionSetNode([
|
||||
'selections' => $this->many(Token::BRACE_L, [$this, 'parseSelection'], Token::BRACE_R),
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -481,7 +481,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Field
|
||||
* @return FieldNode
|
||||
*/
|
||||
function parseField()
|
||||
{
|
||||
@ -496,7 +496,7 @@ class Parser
|
||||
$name = $nameOrAlias;
|
||||
}
|
||||
|
||||
return new Field([
|
||||
return new FieldNode([
|
||||
'alias' => $alias,
|
||||
'name' => $name,
|
||||
'arguments' => $this->parseArguments(),
|
||||
@ -507,7 +507,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Argument>
|
||||
* @return array<ArgumentNode>
|
||||
*/
|
||||
function parseArguments()
|
||||
{
|
||||
@ -517,7 +517,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Argument
|
||||
* @return ArgumentNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseArgument()
|
||||
@ -528,7 +528,7 @@ class Parser
|
||||
$this->expect(Token::COLON);
|
||||
$value = $this->parseValueLiteral(false);
|
||||
|
||||
return new Argument([
|
||||
return new ArgumentNode([
|
||||
'name' => $name,
|
||||
'value' => $value,
|
||||
'loc' => $this->loc($start)
|
||||
@ -538,7 +538,7 @@ class Parser
|
||||
// Implements the parsing rules in the Fragments section.
|
||||
|
||||
/**
|
||||
* @return FragmentSpread|InlineFragment
|
||||
* @return FragmentSpreadNode|InlineFragmentNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseFragment()
|
||||
@ -547,7 +547,7 @@ class Parser
|
||||
$this->expect(Token::SPREAD);
|
||||
|
||||
if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') {
|
||||
return new FragmentSpread([
|
||||
return new FragmentSpreadNode([
|
||||
'name' => $this->parseFragmentName(),
|
||||
'directives' => $this->parseDirectives(),
|
||||
'loc' => $this->loc($start)
|
||||
@ -560,7 +560,7 @@ class Parser
|
||||
$typeCondition = $this->parseNamedType();
|
||||
}
|
||||
|
||||
return new InlineFragment([
|
||||
return new InlineFragmentNode([
|
||||
'typeCondition' => $typeCondition,
|
||||
'directives' => $this->parseDirectives(),
|
||||
'selectionSet' => $this->parseSelectionSet(),
|
||||
@ -569,7 +569,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FragmentDefinition
|
||||
* @return FragmentDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseFragmentDefinition()
|
||||
@ -581,7 +581,7 @@ class Parser
|
||||
$this->expectKeyword('on');
|
||||
$typeCondition = $this->parseNamedType();
|
||||
|
||||
return new FragmentDefinition([
|
||||
return new FragmentDefinitionNode([
|
||||
'name' => $name,
|
||||
'typeCondition' => $typeCondition,
|
||||
'directives' => $this->parseDirectives(),
|
||||
@ -591,7 +591,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name
|
||||
* @return NameNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseFragmentName()
|
||||
@ -623,7 +623,7 @@ class Parser
|
||||
* EnumValue : Name but not `true`, `false` or `null`
|
||||
*
|
||||
* @param $isConst
|
||||
* @return BooleanValue|EnumValue|FloatValue|IntValue|StringValue|Variable|ListValue|ObjectValue|NullValue
|
||||
* @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode|VariableNode|ListValueNode|ObjectValueNode|NullValueNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseValueLiteral($isConst)
|
||||
@ -636,37 +636,37 @@ class Parser
|
||||
return $this->parseObject($isConst);
|
||||
case Token::INT:
|
||||
$this->lexer->advance();
|
||||
return new IntValue([
|
||||
return new IntValueNode([
|
||||
'value' => $token->value,
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
case Token::FLOAT:
|
||||
$this->lexer->advance();
|
||||
return new FloatValue([
|
||||
return new FloatValueNode([
|
||||
'value' => $token->value,
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
case Token::STRING:
|
||||
$this->lexer->advance();
|
||||
return new StringValue([
|
||||
return new StringValueNode([
|
||||
'value' => $token->value,
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
case Token::NAME:
|
||||
if ($token->value === 'true' || $token->value === 'false') {
|
||||
$this->lexer->advance();
|
||||
return new BooleanValue([
|
||||
return new BooleanValueNode([
|
||||
'value' => $token->value === 'true',
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
} else if ($token->value === 'null') {
|
||||
$this->lexer->advance();
|
||||
return new NullValue([
|
||||
return new NullValueNode([
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
} else {
|
||||
$this->lexer->advance();
|
||||
return new EnumValue([
|
||||
return new EnumValueNode([
|
||||
'value' => $token->value,
|
||||
'loc' => $this->loc($token)
|
||||
]);
|
||||
@ -683,7 +683,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BooleanValue|EnumValue|FloatValue|IntValue|StringValue|Variable
|
||||
* @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|StringValueNode|VariableNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseConstValue()
|
||||
@ -692,7 +692,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BooleanValue|EnumValue|FloatValue|IntValue|ListValue|ObjectValue|StringValue|Variable
|
||||
* @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode
|
||||
*/
|
||||
function parseVariableValue()
|
||||
{
|
||||
@ -701,13 +701,13 @@ class Parser
|
||||
|
||||
/**
|
||||
* @param bool $isConst
|
||||
* @return ListValue
|
||||
* @return ListValueNode
|
||||
*/
|
||||
function parseArray($isConst)
|
||||
{
|
||||
$start = $this->lexer->token;
|
||||
$item = $isConst ? 'parseConstValue' : 'parseVariableValue';
|
||||
return new ListValue([
|
||||
return new ListValueNode([
|
||||
'values' => $this->any(Token::BRACKET_L, [$this, $item], Token::BRACKET_R),
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -715,7 +715,7 @@ class Parser
|
||||
|
||||
/**
|
||||
* @param $isConst
|
||||
* @return ObjectValue
|
||||
* @return ObjectValueNode
|
||||
*/
|
||||
function parseObject($isConst)
|
||||
{
|
||||
@ -725,7 +725,7 @@ class Parser
|
||||
while (!$this->skip(Token::BRACE_R)) {
|
||||
$fields[] = $this->parseObjectField($isConst);
|
||||
}
|
||||
return new ObjectValue([
|
||||
return new ObjectValueNode([
|
||||
'fields' => $fields,
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -733,7 +733,7 @@ class Parser
|
||||
|
||||
/**
|
||||
* @param $isConst
|
||||
* @return ObjectField
|
||||
* @return ObjectFieldNode
|
||||
*/
|
||||
function parseObjectField($isConst)
|
||||
{
|
||||
@ -742,7 +742,7 @@ class Parser
|
||||
|
||||
$this->expect(Token::COLON);
|
||||
|
||||
return new ObjectField([
|
||||
return new ObjectFieldNode([
|
||||
'name' => $name,
|
||||
'value' => $this->parseValueLiteral($isConst),
|
||||
'loc' => $this->loc($start)
|
||||
@ -752,7 +752,7 @@ class Parser
|
||||
// Implements the parsing rules in the Directives section.
|
||||
|
||||
/**
|
||||
* @return array<Directive>
|
||||
* @return array<DirectiveNode>
|
||||
*/
|
||||
function parseDirectives()
|
||||
{
|
||||
@ -764,14 +764,14 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Directive
|
||||
* @return DirectiveNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseDirective()
|
||||
{
|
||||
$start = $this->lexer->token;
|
||||
$this->expect(Token::AT);
|
||||
return new Directive([
|
||||
return new DirectiveNode([
|
||||
'name' => $this->parseName(),
|
||||
'arguments' => $this->parseArguments(),
|
||||
'loc' => $this->loc($start)
|
||||
@ -783,7 +783,7 @@ class Parser
|
||||
/**
|
||||
* Handles the Type: TypeName, ListType, and NonNullType parsing rules.
|
||||
*
|
||||
* @return ListType|Name|NonNullType
|
||||
* @return ListTypeNode|NameNode|NonNullTypeNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseTypeReference()
|
||||
@ -793,7 +793,7 @@ class Parser
|
||||
if ($this->skip(Token::BRACKET_L)) {
|
||||
$type = $this->parseTypeReference();
|
||||
$this->expect(Token::BRACKET_R);
|
||||
$type = new ListType([
|
||||
$type = new ListTypeNode([
|
||||
'type' => $type,
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -801,7 +801,7 @@ class Parser
|
||||
$type = $this->parseNamedType();
|
||||
}
|
||||
if ($this->skip(Token::BANG)) {
|
||||
return new NonNullType([
|
||||
return new NonNullTypeNode([
|
||||
'type' => $type,
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -814,7 +814,7 @@ class Parser
|
||||
{
|
||||
$start = $this->lexer->token;
|
||||
|
||||
return new NamedType([
|
||||
return new NamedTypeNode([
|
||||
'name' => $this->parseName(),
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -837,7 +837,7 @@ class Parser
|
||||
* - EnumTypeDefinition
|
||||
* - InputObjectTypeDefinition
|
||||
*
|
||||
* @return TypeSystemDefinition
|
||||
* @return TypeSystemDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseTypeSystemDefinition()
|
||||
@ -860,7 +860,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SchemaDefinition
|
||||
* @return SchemaDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseSchemaDefinition()
|
||||
@ -875,7 +875,7 @@ class Parser
|
||||
Token::BRACE_R
|
||||
);
|
||||
|
||||
return new SchemaDefinition([
|
||||
return new SchemaDefinitionNode([
|
||||
'directives' => $directives,
|
||||
'operationTypes' => $operationTypes,
|
||||
'loc' => $this->loc($start)
|
||||
@ -883,7 +883,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OperationTypeDefinition
|
||||
* @return OperationTypeDefinitionNode
|
||||
*/
|
||||
function parseOperationTypeDefinition()
|
||||
{
|
||||
@ -892,7 +892,7 @@ class Parser
|
||||
$this->expect(Token::COLON);
|
||||
$type = $this->parseNamedType();
|
||||
|
||||
return new OperationTypeDefinition([
|
||||
return new OperationTypeDefinitionNode([
|
||||
'operation' => $operation,
|
||||
'type' => $type,
|
||||
'loc' => $this->loc($start)
|
||||
@ -900,7 +900,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ScalarTypeDefinition
|
||||
* @return ScalarTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseScalarTypeDefinition()
|
||||
@ -910,7 +910,7 @@ class Parser
|
||||
$name = $this->parseName();
|
||||
$directives = $this->parseDirectives();
|
||||
|
||||
return new ScalarTypeDefinition([
|
||||
return new ScalarTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'loc' => $this->loc($start)
|
||||
@ -918,7 +918,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectTypeDefinition
|
||||
* @return ObjectTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseObjectTypeDefinition()
|
||||
@ -935,7 +935,7 @@ class Parser
|
||||
Token::BRACE_R
|
||||
);
|
||||
|
||||
return new ObjectTypeDefinition([
|
||||
return new ObjectTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'interfaces' => $interfaces,
|
||||
'directives' => $directives,
|
||||
@ -945,7 +945,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NamedType[]
|
||||
* @return NamedTypeNode[]
|
||||
*/
|
||||
function parseImplementsInterfaces()
|
||||
{
|
||||
@ -960,7 +960,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FieldDefinition
|
||||
* @return FieldDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseFieldDefinition()
|
||||
@ -972,7 +972,7 @@ class Parser
|
||||
$type = $this->parseTypeReference();
|
||||
$directives = $this->parseDirectives();
|
||||
|
||||
return new FieldDefinition([
|
||||
return new FieldDefinitionNode([
|
||||
'name' => $name,
|
||||
'arguments' => $args,
|
||||
'type' => $type,
|
||||
@ -982,7 +982,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InputValueDefinition[]
|
||||
* @return InputValueDefinitionNode[]
|
||||
*/
|
||||
function parseArgumentDefs()
|
||||
{
|
||||
@ -993,7 +993,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InputValueDefinition
|
||||
* @return InputValueDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseInputValueDef()
|
||||
@ -1007,7 +1007,7 @@ class Parser
|
||||
$defaultValue = $this->parseConstValue();
|
||||
}
|
||||
$directives = $this->parseDirectives();
|
||||
return new InputValueDefinition([
|
||||
return new InputValueDefinitionNode([
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'defaultValue' => $defaultValue,
|
||||
@ -1017,7 +1017,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InterfaceTypeDefinition
|
||||
* @return InterfaceTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseInterfaceTypeDefinition()
|
||||
@ -1032,7 +1032,7 @@ class Parser
|
||||
Token::BRACE_R
|
||||
);
|
||||
|
||||
return new InterfaceTypeDefinition([
|
||||
return new InterfaceTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'fields' => $fields,
|
||||
@ -1041,7 +1041,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UnionTypeDefinition
|
||||
* @return UnionTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseUnionTypeDefinition()
|
||||
@ -1053,7 +1053,7 @@ class Parser
|
||||
$this->expect(Token::EQUALS);
|
||||
$types = $this->parseUnionMembers();
|
||||
|
||||
return new UnionTypeDefinition([
|
||||
return new UnionTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'types' => $types,
|
||||
@ -1066,7 +1066,7 @@ class Parser
|
||||
* - NamedType
|
||||
* - UnionMembers | NamedType
|
||||
*
|
||||
* @return NamedType[]
|
||||
* @return NamedTypeNode[]
|
||||
*/
|
||||
function parseUnionMembers()
|
||||
{
|
||||
@ -1078,7 +1078,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnumTypeDefinition
|
||||
* @return EnumTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseEnumTypeDefinition()
|
||||
@ -1093,7 +1093,7 @@ class Parser
|
||||
Token::BRACE_R
|
||||
);
|
||||
|
||||
return new EnumTypeDefinition([
|
||||
return new EnumTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'values' => $values,
|
||||
@ -1102,7 +1102,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnumValueDefinition
|
||||
* @return EnumValueDefinitionNode
|
||||
*/
|
||||
function parseEnumValueDefinition()
|
||||
{
|
||||
@ -1110,7 +1110,7 @@ class Parser
|
||||
$name = $this->parseName();
|
||||
$directives = $this->parseDirectives();
|
||||
|
||||
return new EnumValueDefinition([
|
||||
return new EnumValueDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'loc' => $this->loc($start)
|
||||
@ -1118,7 +1118,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InputObjectTypeDefinition
|
||||
* @return InputObjectTypeDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseInputObjectTypeDefinition()
|
||||
@ -1133,7 +1133,7 @@ class Parser
|
||||
Token::BRACE_R
|
||||
);
|
||||
|
||||
return new InputObjectTypeDefinition([
|
||||
return new InputObjectTypeDefinitionNode([
|
||||
'name' => $name,
|
||||
'directives' => $directives,
|
||||
'fields' => $fields,
|
||||
@ -1142,7 +1142,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TypeExtensionDefinition
|
||||
* @return TypeExtensionDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseTypeExtensionDefinition()
|
||||
@ -1151,7 +1151,7 @@ class Parser
|
||||
$this->expectKeyword('extend');
|
||||
$definition = $this->parseObjectTypeDefinition();
|
||||
|
||||
return new TypeExtensionDefinition([
|
||||
return new TypeExtensionDefinitionNode([
|
||||
'definition' => $definition,
|
||||
'loc' => $this->loc($start)
|
||||
]);
|
||||
@ -1161,7 +1161,7 @@ class Parser
|
||||
* DirectiveDefinition :
|
||||
* - directive @ Name ArgumentsDefinition? on DirectiveLocations
|
||||
*
|
||||
* @return DirectiveDefinition
|
||||
* @return DirectiveDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseDirectiveDefinition()
|
||||
@ -1174,7 +1174,7 @@ class Parser
|
||||
$this->expectKeyword('on');
|
||||
$locations = $this->parseDirectiveLocations();
|
||||
|
||||
return new DirectiveDefinition([
|
||||
return new DirectiveDefinitionNode([
|
||||
'name' => $name,
|
||||
'arguments' => $args,
|
||||
'locations' => $locations,
|
||||
@ -1183,7 +1183,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name[]
|
||||
* @return NameNode[]
|
||||
*/
|
||||
function parseDirectiveLocations()
|
||||
{
|
||||
|
@ -1,43 +1,43 @@
|
||||
<?php
|
||||
namespace GraphQL\Language;
|
||||
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\DirectiveDefinition;
|
||||
use GraphQL\Language\AST\EnumTypeDefinition;
|
||||
use GraphQL\Language\AST\EnumValueDefinition;
|
||||
use GraphQL\Language\AST\FieldDefinition;
|
||||
use GraphQL\Language\AST\InputObjectTypeDefinition;
|
||||
use GraphQL\Language\AST\InputValueDefinition;
|
||||
use GraphQL\Language\AST\InterfaceTypeDefinition;
|
||||
use GraphQL\Language\AST\ListValue;
|
||||
use GraphQL\Language\AST\BooleanValue;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\EnumValue;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FloatValue;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\ListType;
|
||||
use GraphQL\Language\AST\NamedType;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\DirectiveDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumValueDefinitionNode;
|
||||
use GraphQL\Language\AST\FieldDefinitionNode;
|
||||
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\InputValueDefinitionNode;
|
||||
use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ListValueNode;
|
||||
use GraphQL\Language\AST\BooleanValueNode;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\DocumentNode;
|
||||
use GraphQL\Language\AST\EnumValueNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\FloatValueNode;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\InlineFragmentNode;
|
||||
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\NonNullType;
|
||||
use GraphQL\Language\AST\NullValue;
|
||||
use GraphQL\Language\AST\ObjectField;
|
||||
use GraphQL\Language\AST\ObjectTypeDefinition;
|
||||
use GraphQL\Language\AST\ObjectValue;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationTypeDefinition;
|
||||
use GraphQL\Language\AST\ScalarTypeDefinition;
|
||||
use GraphQL\Language\AST\SchemaDefinition;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\TypeExtensionDefinition;
|
||||
use GraphQL\Language\AST\UnionTypeDefinition;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\NonNullTypeNode;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ObjectFieldNode;
|
||||
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ObjectValueNode;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\OperationTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\SchemaDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Language\AST\TypeExtensionDefinitionNode;
|
||||
use GraphQL\Language\AST\UnionTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
|
||||
class Printer
|
||||
{
|
||||
@ -61,10 +61,10 @@ class Printer
|
||||
NodeType::VARIABLE => function($node) {
|
||||
return '$' . $node->name;
|
||||
},
|
||||
NodeType::DOCUMENT => function(Document $node) {
|
||||
NodeType::DOCUMENT => function(DocumentNode $node) {
|
||||
return $this->join($node->definitions, "\n\n") . "\n";
|
||||
},
|
||||
NodeType::OPERATION_DEFINITION => function(OperationDefinition $node) {
|
||||
NodeType::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(VariableDefinition $node) {
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) {
|
||||
return $node->variable . ': ' . $node->type . $this->wrap(' = ', $node->defaultValue);
|
||||
},
|
||||
NodeType::SELECTION_SET => function(SelectionSet $node) {
|
||||
NodeType::SELECTION_SET => function(SelectionSetNode $node) {
|
||||
return $this->block($node->selections);
|
||||
},
|
||||
NodeType::FIELD => function(Field $node) {
|
||||
NodeType::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(Argument $node) {
|
||||
NodeType::ARGUMENT => function(ArgumentNode $node) {
|
||||
return $node->name . ': ' . $node->value;
|
||||
},
|
||||
|
||||
// Fragments
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) {
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) {
|
||||
return '...' . $node->name . $this->wrap(' ', $this->join($node->directives, ' '));
|
||||
},
|
||||
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) {
|
||||
NodeType::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(FragmentDefinition $node) {
|
||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
|
||||
return "fragment {$node->name} on {$node->typeCondition} "
|
||||
. $this->wrap('', $this->join($node->directives, ' '), ' ')
|
||||
. $node->selectionSet;
|
||||
},
|
||||
|
||||
// Value
|
||||
NodeType::INT => function(IntValue $node) {
|
||||
NodeType::INT => function(IntValueNode $node) {
|
||||
return $node->value;
|
||||
},
|
||||
NodeType::FLOAT => function(FloatValue $node) {
|
||||
NodeType::FLOAT => function(FloatValueNode $node) {
|
||||
return $node->value;
|
||||
},
|
||||
NodeType::STRING => function(StringValue $node) {
|
||||
NodeType::STRING => function(StringValueNode $node) {
|
||||
return json_encode($node->value);
|
||||
},
|
||||
NodeType::BOOLEAN => function(BooleanValue $node) {
|
||||
NodeType::BOOLEAN => function(BooleanValueNode $node) {
|
||||
return $node->value ? 'true' : 'false';
|
||||
},
|
||||
NodeType::NULL => function(NullValue $node) {
|
||||
NodeType::NULL => function(NullValueNode $node) {
|
||||
return 'null';
|
||||
},
|
||||
NodeType::ENUM => function(EnumValue $node) {
|
||||
NodeType::ENUM => function(EnumValueNode $node) {
|
||||
return $node->value;
|
||||
},
|
||||
NodeType::LST => function(ListValue $node) {
|
||||
NodeType::LST => function(ListValueNode $node) {
|
||||
return '[' . $this->join($node->values, ', ') . ']';
|
||||
},
|
||||
NodeType::OBJECT => function(ObjectValue $node) {
|
||||
NodeType::OBJECT => function(ObjectValueNode $node) {
|
||||
return '{' . $this->join($node->fields, ', ') . '}';
|
||||
},
|
||||
NodeType::OBJECT_FIELD => function(ObjectField $node) {
|
||||
NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) {
|
||||
return $node->name . ': ' . $node->value;
|
||||
},
|
||||
|
||||
// Directive
|
||||
NodeType::DIRECTIVE => function(Directive $node) {
|
||||
// DirectiveNode
|
||||
NodeType::DIRECTIVE => function(DirectiveNode $node) {
|
||||
return '@' . $node->name . $this->wrap('(', $this->join($node->arguments, ', '), ')');
|
||||
},
|
||||
|
||||
// Type
|
||||
NodeType::NAMED_TYPE => function(NamedType $node) {
|
||||
NodeType::NAMED_TYPE => function(NamedTypeNode $node) {
|
||||
return $node->name;
|
||||
},
|
||||
NodeType::LIST_TYPE => function(ListType $node) {
|
||||
NodeType::LIST_TYPE => function(ListTypeNode $node) {
|
||||
return '[' . $node->type . ']';
|
||||
},
|
||||
NodeType::NON_NULL_TYPE => function(NonNullType $node) {
|
||||
NodeType::NON_NULL_TYPE => function(NonNullTypeNode $node) {
|
||||
return $node->type . '!';
|
||||
},
|
||||
|
||||
// Type System Definitions
|
||||
NodeType::SCHEMA_DEFINITION => function(SchemaDefinition $def) {
|
||||
NodeType::SCHEMA_DEFINITION => function(SchemaDefinitionNode $def) {
|
||||
return $this->join([
|
||||
'schema',
|
||||
$this->join($def->directives, ' '),
|
||||
$this->block($def->operationTypes)
|
||||
], ' ');
|
||||
},
|
||||
NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinition $def) {
|
||||
NodeType::OPERATION_TYPE_DEFINITION => function(OperationTypeDefinitionNode $def) {
|
||||
return $def->operation . ': ' . $def->type;
|
||||
},
|
||||
|
||||
NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinition $def) {
|
||||
NodeType::SCALAR_TYPE_DEFINITION => function(ScalarTypeDefinitionNode $def) {
|
||||
return $this->join(['scalar', $def->name, $this->join($def->directives, ' ')], ' ');
|
||||
},
|
||||
NodeType::OBJECT_TYPE_DEFINITION => function(ObjectTypeDefinition $def) {
|
||||
NodeType::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(FieldDefinition $def) {
|
||||
NodeType::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(InputValueDefinition $def) {
|
||||
NodeType::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(InterfaceTypeDefinition $def) {
|
||||
NodeType::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(UnionTypeDefinition $def) {
|
||||
NodeType::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(EnumTypeDefinition $def) {
|
||||
NodeType::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(EnumValueDefinition $def) {
|
||||
NodeType::ENUM_VALUE_DEFINITION => function(EnumValueDefinitionNode $def) {
|
||||
return $this->join([
|
||||
$def->name,
|
||||
$this->join($def->directives, ' ')
|
||||
], ' ');
|
||||
},
|
||||
NodeType::INPUT_OBJECT_TYPE_DEFINITION => function(InputObjectTypeDefinition $def) {
|
||||
NodeType::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(TypeExtensionDefinition $def) {
|
||||
NodeType::TYPE_EXTENSION_DEFINITION => function(TypeExtensionDefinitionNode $def) {
|
||||
return "extend {$def->definition}";
|
||||
},
|
||||
NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinition $def) {
|
||||
NodeType::DIRECTIVE_DEFINITION => function(DirectiveDefinitionNode $def) {
|
||||
return 'directive @' . $def->name . $this->wrap('(', $this->join($def->arguments, ', '), ')')
|
||||
. ' on ' . $this->join($def->locations, ' | ');
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Language\AST\BooleanValue;
|
||||
use GraphQL\Language\AST\BooleanValueNode;
|
||||
|
||||
/**
|
||||
* Class BooleanType
|
||||
@ -43,7 +43,7 @@ class BooleanType extends ScalarType
|
||||
*/
|
||||
public function parseLiteral($ast)
|
||||
{
|
||||
if ($ast instanceof BooleanValue) {
|
||||
if ($ast instanceof BooleanValueNode) {
|
||||
return (bool) $ast->value;
|
||||
}
|
||||
return null;
|
||||
|
@ -45,7 +45,7 @@ class CustomScalarType extends ScalarType
|
||||
* @param $valueAST
|
||||
* @return mixed
|
||||
*/
|
||||
public function parseLiteral(/* GraphQL\Language\AST\Value */ $valueAST)
|
||||
public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueAST)
|
||||
{
|
||||
return call_user_func($this->config['parseLiteral'], $valueAST);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Language\AST\EnumValue;
|
||||
use GraphQL\Language\AST\EnumValueNode;
|
||||
use GraphQL\Utils;
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType
|
||||
*/
|
||||
public function parseLiteral($value)
|
||||
{
|
||||
if ($value instanceof EnumValue) {
|
||||
if ($value instanceof EnumValueNode) {
|
||||
$lookup = $this->getNameLookup();
|
||||
if (isset($lookup[$value->value])) {
|
||||
$enumValue = $lookup[$value->value];
|
||||
@ -124,7 +124,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayObject<string, GraphQLEnumValueDefinition>
|
||||
* @return \ArrayObject<string, EnumValueDefinition>
|
||||
*/
|
||||
private function getNameLookup()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace GraphQL\Type\Definition;
|
||||
* Class FieldArgument
|
||||
*
|
||||
* @package GraphQL\Type\Definition
|
||||
* @todo Rename to Argument as it is also applicable to directives, not only fields
|
||||
* @todo Rename to ArgumentNode as it is also applicable to directives, not only fields
|
||||
*/
|
||||
class FieldArgument
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\FloatValue;
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\FloatValueNode;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Utils;
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ values as specified by
|
||||
*/
|
||||
public function parseLiteral($ast)
|
||||
{
|
||||
if ($ast instanceof FloatValue || $ast instanceof IntValue) {
|
||||
if ($ast instanceof FloatValueNode || $ast instanceof IntValueNode) {
|
||||
return (float) $ast->value;
|
||||
}
|
||||
return null;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
|
||||
/**
|
||||
* Class IDType
|
||||
@ -55,7 +55,7 @@ When expected as an input type, any string (such as `"4"`) or integer
|
||||
*/
|
||||
public function parseLiteral($ast)
|
||||
{
|
||||
if ($ast instanceof StringValue || $ast instanceof IntValue) {
|
||||
if ($ast instanceof StringValueNode || $ast instanceof IntValueNode) {
|
||||
return $ast->value;
|
||||
}
|
||||
return null;
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\Value;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Language\AST\ValueNode;
|
||||
use GraphQL\Utils;
|
||||
|
||||
/**
|
||||
@ -78,7 +78,7 @@ values. Int can represent values between -(2^31) and 2^31 - 1. ';
|
||||
*/
|
||||
public function parseLiteral($ast)
|
||||
{
|
||||
if ($ast instanceof IntValue) {
|
||||
if ($ast instanceof IntValueNode) {
|
||||
$val = (int) $ast->value;
|
||||
if ($ast->value === (string) $val && self::MIN_INT <= $val && $val <= self::MAX_INT) {
|
||||
return $val;
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\Selection;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Schema;
|
||||
use GraphQL\Utils;
|
||||
|
||||
@ -22,7 +22,7 @@ class ResolveInfo
|
||||
public $fieldName;
|
||||
|
||||
/**
|
||||
* @var Field[]
|
||||
* @var FieldNode[]
|
||||
*/
|
||||
public $fieldASTs;
|
||||
|
||||
@ -57,7 +57,7 @@ class ResolveInfo
|
||||
public $rootValue;
|
||||
|
||||
/**
|
||||
* @var OperationDefinition
|
||||
* @var OperationDefinitionNode
|
||||
*/
|
||||
public $operation;
|
||||
|
||||
@ -106,7 +106,7 @@ class ResolveInfo
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
/** @var Field $fieldAST */
|
||||
/** @var FieldNode $fieldAST */
|
||||
foreach ($this->fieldASTs as $fieldAST) {
|
||||
$fields = array_merge_recursive($fields, $this->foldSelectionSet($fieldAST->selectionSet, $depth));
|
||||
}
|
||||
@ -114,19 +114,19 @@ class ResolveInfo
|
||||
return $fields;
|
||||
}
|
||||
|
||||
private function foldSelectionSet(SelectionSet $selectionSet, $descend)
|
||||
private function foldSelectionSet(SelectionSetNode $selectionSet, $descend)
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
foreach ($selectionSet->selections as $selectionAST) {
|
||||
if ($selectionAST instanceof Field) {
|
||||
if ($selectionAST instanceof FieldNode) {
|
||||
$fields[$selectionAST->name->value] = $descend > 0 && !empty($selectionAST->selectionSet)
|
||||
? $this->foldSelectionSet($selectionAST->selectionSet, $descend - 1)
|
||||
: true;
|
||||
} else if ($selectionAST instanceof FragmentSpread) {
|
||||
} else if ($selectionAST instanceof FragmentSpreadNode) {
|
||||
$spreadName = $selectionAST->name->value;
|
||||
if (isset($this->fragments[$spreadName])) {
|
||||
/** @var FragmentDefinition $fragment */
|
||||
/** @var FragmentDefinitionNode $fragment */
|
||||
$fragment = $this->fragments[$spreadName];
|
||||
$fields += $this->foldSelectionSet($fragment->selectionSet, $descend);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Type\Definition;
|
||||
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
|
||||
/**
|
||||
* Class StringType
|
||||
@ -52,7 +52,7 @@ represent free-form human-readable text.';
|
||||
*/
|
||||
public function parseLiteral($ast)
|
||||
{
|
||||
if ($ast instanceof StringValue) {
|
||||
if ($ast instanceof StringValueNode) {
|
||||
return $ast->value;
|
||||
}
|
||||
return null;
|
||||
|
@ -2,19 +2,19 @@
|
||||
namespace GraphQL\Utils;
|
||||
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\BooleanValue;
|
||||
use GraphQL\Language\AST\EnumValue;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FloatValue;
|
||||
use GraphQL\Language\AST\IntValue;
|
||||
use GraphQL\Language\AST\ListValue;
|
||||
use GraphQL\Language\AST\Name;
|
||||
use GraphQL\Language\AST\NullValue;
|
||||
use GraphQL\Language\AST\ObjectField;
|
||||
use GraphQL\Language\AST\ObjectValue;
|
||||
use GraphQL\Language\AST\StringValue;
|
||||
use GraphQL\Language\AST\Value;
|
||||
use GraphQL\Language\AST\Variable;
|
||||
use GraphQL\Language\AST\BooleanValueNode;
|
||||
use GraphQL\Language\AST\EnumValueNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\FloatValueNode;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Language\AST\ListValueNode;
|
||||
use GraphQL\Language\AST\NameNode;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ObjectFieldNode;
|
||||
use GraphQL\Language\AST\ObjectValueNode;
|
||||
use GraphQL\Language\AST\StringValueNode;
|
||||
use GraphQL\Language\AST\ValueNode;
|
||||
use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\IDType;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
@ -50,20 +50,20 @@ class AST
|
||||
*
|
||||
* @param $value
|
||||
* @param InputType $type
|
||||
* @return ObjectValue|ListValue|BooleanValue|IntValue|FloatValue|EnumValue|StringValue|NullValue
|
||||
* @return ObjectValueNode|ListValueNode|BooleanValueNode|IntValueNode|FloatValueNode|EnumValueNode|StringValueNode|NullValueNode
|
||||
*/
|
||||
static function astFromValue($value, InputType $type)
|
||||
{
|
||||
if ($type instanceof NonNull) {
|
||||
$astValue = self::astFromValue($value, $type->getWrappedType());
|
||||
if ($astValue instanceof NullValue) {
|
||||
if ($astValue instanceof NullValueNode) {
|
||||
return null;
|
||||
}
|
||||
return $astValue;
|
||||
}
|
||||
|
||||
if ($value === null) {
|
||||
return new NullValue([]);
|
||||
return new NullValueNode([]);
|
||||
}
|
||||
|
||||
// Convert PHP array to GraphQL list. If the GraphQLType is a list, but
|
||||
@ -78,7 +78,7 @@ class AST
|
||||
$valuesASTs[] = $itemAST;
|
||||
}
|
||||
}
|
||||
return new ListValue(['values' => $valuesASTs]);
|
||||
return new ListValueNode(['values' => $valuesASTs]);
|
||||
}
|
||||
return self::astFromValue($value, $itemType);
|
||||
}
|
||||
@ -117,14 +117,14 @@ class AST
|
||||
$fieldNode = self::astFromValue($fieldValue, $field->getType());
|
||||
|
||||
if ($fieldNode) {
|
||||
$fieldASTs[] = new ObjectField([
|
||||
'name' => new Name(['value' => $fieldName]),
|
||||
$fieldASTs[] = new ObjectFieldNode([
|
||||
'name' => new NameNode(['value' => $fieldName]),
|
||||
'value' => $fieldNode
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ObjectValue(['fields' => $fieldASTs]);
|
||||
return new ObjectValueNode(['fields' => $fieldASTs]);
|
||||
}
|
||||
|
||||
// Since value is an internally represented value, it must be serialized
|
||||
@ -141,32 +141,32 @@ class AST
|
||||
|
||||
// Others serialize based on their corresponding PHP scalar types.
|
||||
if (is_bool($serialized)) {
|
||||
return new BooleanValue(['value' => $serialized]);
|
||||
return new BooleanValueNode(['value' => $serialized]);
|
||||
}
|
||||
if (is_int($serialized)) {
|
||||
return new IntValue(['value' => $serialized]);
|
||||
return new IntValueNode(['value' => $serialized]);
|
||||
}
|
||||
if (is_float($serialized)) {
|
||||
if ((int) $serialized == $serialized) {
|
||||
return new IntValue(['value' => $serialized]);
|
||||
return new IntValueNode(['value' => $serialized]);
|
||||
}
|
||||
return new FloatValue(['value' => $serialized]);
|
||||
return new FloatValueNode(['value' => $serialized]);
|
||||
}
|
||||
if (is_string($serialized)) {
|
||||
// Enum types use Enum literals.
|
||||
if ($type instanceof EnumType) {
|
||||
return new EnumValue(['value' => $serialized]);
|
||||
return new EnumValueNode(['value' => $serialized]);
|
||||
}
|
||||
|
||||
// ID types can use Int literals.
|
||||
$asInt = (int) $serialized;
|
||||
if ($type instanceof IDType && (string) $asInt === $serialized) {
|
||||
return new IntValue(['value' => $serialized]);
|
||||
return new IntValueNode(['value' => $serialized]);
|
||||
}
|
||||
|
||||
// Use json_encode, which uses the same string encoding as GraphQL,
|
||||
// then remove the quotes.
|
||||
return new StringValue([
|
||||
return new StringValueNode([
|
||||
'value' => substr(json_encode($serialized), 1, -1)
|
||||
]);
|
||||
}
|
||||
@ -210,19 +210,19 @@ class AST
|
||||
}
|
||||
|
||||
if ($type instanceof NonNull) {
|
||||
if ($valueAST instanceof NullValue) {
|
||||
if ($valueAST instanceof NullValueNode) {
|
||||
// Invalid: intentionally return no value.
|
||||
return $undefined;
|
||||
}
|
||||
return self::valueFromAST($valueAST, $type->getWrappedType(), $variables);
|
||||
}
|
||||
|
||||
if ($valueAST instanceof NullValue) {
|
||||
if ($valueAST instanceof NullValueNode) {
|
||||
// This is explicitly returning the value null.
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($valueAST instanceof Variable) {
|
||||
if ($valueAST instanceof VariableNode) {
|
||||
$variableName = $valueAST->name->value;
|
||||
|
||||
if (!$variables || !array_key_exists($variableName, $variables)) {
|
||||
@ -238,7 +238,7 @@ class AST
|
||||
if ($type instanceof ListOfType) {
|
||||
$itemType = $type->getWrappedType();
|
||||
|
||||
if ($valueAST instanceof ListValue) {
|
||||
if ($valueAST instanceof ListValueNode) {
|
||||
$coercedValues = [];
|
||||
$itemASTs = $valueAST->values;
|
||||
foreach ($itemASTs as $itemAST) {
|
||||
@ -270,7 +270,7 @@ class AST
|
||||
}
|
||||
|
||||
if ($type instanceof InputObjectType) {
|
||||
if (!$valueAST instanceof ObjectValue) {
|
||||
if (!$valueAST instanceof ObjectValueNode) {
|
||||
// Invalid: intentionally return no value.
|
||||
return $undefined;
|
||||
}
|
||||
@ -279,7 +279,7 @@ class AST
|
||||
$fields = $type->getFields();
|
||||
$fieldASTs = Utils::keyMap($valueAST->fields, function($field) {return $field->name->value;});
|
||||
foreach ($fields as $field) {
|
||||
/** @var Value $fieldAST */
|
||||
/** @var ValueNode $fieldAST */
|
||||
$fieldName = $field->name;
|
||||
$fieldAST = isset($fieldASTs[$fieldName]) ? $fieldASTs[$fieldName] : null;
|
||||
|
||||
@ -329,7 +329,7 @@ class AST
|
||||
*/
|
||||
private static function isMissingVariable($valueAST, $variables)
|
||||
{
|
||||
return $valueAST instanceof Variable &&
|
||||
return $valueAST instanceof VariableNode &&
|
||||
(!$variables || !array_key_exists($valueAST->name->value, $variables));
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace GraphQL\Utils;
|
||||
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\ListType;
|
||||
use GraphQL\Language\AST\NamedType;
|
||||
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\NonNullType;
|
||||
use GraphQL\Language\AST\NonNullTypeNode;
|
||||
use GraphQL\Schema;
|
||||
use GraphQL\Type\Definition\AbstractType;
|
||||
use GraphQL\Type\Definition\CompositeType;
|
||||
@ -149,16 +149,16 @@ class TypeInfo
|
||||
*/
|
||||
public static function typeFromAST(Schema $schema, $inputTypeAst)
|
||||
{
|
||||
if ($inputTypeAst instanceof ListType) {
|
||||
if ($inputTypeAst instanceof ListTypeNode) {
|
||||
$innerType = self::typeFromAST($schema, $inputTypeAst->type);
|
||||
return $innerType ? new ListOfType($innerType) : null;
|
||||
}
|
||||
if ($inputTypeAst instanceof NonNullType) {
|
||||
if ($inputTypeAst instanceof NonNullTypeNode) {
|
||||
$innerType = self::typeFromAST($schema, $inputTypeAst->type);
|
||||
return $innerType ? new NonNull($innerType) : null;
|
||||
}
|
||||
|
||||
Utils::invariant($inputTypeAst && $inputTypeAst instanceof NamedType, 'Must be a named type');
|
||||
Utils::invariant($inputTypeAst && $inputTypeAst instanceof NamedTypeNode, 'Must be a named type');
|
||||
return $schema->getType($inputTypeAst->name->value);
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ class TypeInfo
|
||||
*
|
||||
* @return FieldDefinition
|
||||
*/
|
||||
static private function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST)
|
||||
static private function getFieldDefinition(Schema $schema, Type $parentType, FieldNode $fieldAST)
|
||||
{
|
||||
$name = $fieldAST->name->value;
|
||||
$schemaMeta = Introspection::schemaMetaFieldDef();
|
||||
|
@ -3,14 +3,14 @@ namespace GraphQL\Validator;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Language\AST\ListValue;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
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\NullValue;
|
||||
use GraphQL\Language\AST\Value;
|
||||
use GraphQL\Language\AST\Variable;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ValueNode;
|
||||
use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Language\VisitorOperation;
|
||||
@ -120,7 +120,7 @@ class DocumentValidator
|
||||
self::$rules[$name] = $rule;
|
||||
}
|
||||
|
||||
public static function validate(Schema $schema, Document $ast, array $rules = null)
|
||||
public static function validate(Schema $schema, DocumentNode $ast, array $rules = null)
|
||||
{
|
||||
$typeInfo = new TypeInfo($schema);
|
||||
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules());
|
||||
@ -157,26 +157,26 @@ class DocumentValidator
|
||||
{
|
||||
// A value must be provided if the type is non-null.
|
||||
if ($type instanceof NonNull) {
|
||||
if (!$valueAST || $valueAST instanceof NullValue) {
|
||||
if (!$valueAST || $valueAST instanceof NullValueNode) {
|
||||
return [ 'Expected "' . Utils::printSafe($type) . '", found null.' ];
|
||||
}
|
||||
return static::isValidLiteralValue($type->getWrappedType(), $valueAST);
|
||||
}
|
||||
|
||||
if (!$valueAST || $valueAST instanceof NullValue) {
|
||||
if (!$valueAST || $valueAST instanceof NullValueNode) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// This function only tests literals, and assumes variables will provide
|
||||
// values of the correct type.
|
||||
if ($valueAST instanceof Variable) {
|
||||
if ($valueAST instanceof VariableNode) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Lists accept a non-list value as a list of one.
|
||||
if ($type instanceof ListOfType) {
|
||||
$itemType = $type->getWrappedType();
|
||||
if ($valueAST instanceof ListValue) {
|
||||
if ($valueAST instanceof ListValueNode) {
|
||||
$errors = [];
|
||||
foreach($valueAST->values as $index => $itemAST) {
|
||||
$tmp = static::isValidLiteralValue($itemType, $itemAST);
|
||||
@ -250,11 +250,11 @@ class DocumentValidator
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param TypeInfo $typeInfo
|
||||
* @param Document $documentAST
|
||||
* @param DocumentNode $documentAST
|
||||
* @param array $rules
|
||||
* @return array
|
||||
*/
|
||||
public static function visitUsingRules(Schema $schema, TypeInfo $typeInfo, Document $documentAST, array $rules)
|
||||
public static function visitUsingRules(Schema $schema, TypeInfo $typeInfo, DocumentNode $documentAST, array $rules)
|
||||
{
|
||||
$context = new ValidationContext($schema, $documentAST, $typeInfo);
|
||||
$visitors = [];
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
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\SelectionSet;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Introspection;
|
||||
use GraphQL\Utils\TypeInfo;
|
||||
@ -19,12 +19,12 @@ abstract class AbstractQuerySecurity
|
||||
const DISABLED = 0;
|
||||
|
||||
/**
|
||||
* @var FragmentDefinition[]
|
||||
* @var FragmentDefinitionNode[]
|
||||
*/
|
||||
private $fragments = [];
|
||||
|
||||
/**
|
||||
* @return \GraphQL\Language\AST\FragmentDefinition[]
|
||||
* @return \GraphQL\Language\AST\FragmentDefinitionNode[]
|
||||
*/
|
||||
protected function getFragments()
|
||||
{
|
||||
@ -49,13 +49,13 @@ abstract class AbstractQuerySecurity
|
||||
// Importantly this does not include inline fragments.
|
||||
$definitions = $context->getDocument()->definitions;
|
||||
foreach ($definitions as $node) {
|
||||
if ($node instanceof FragmentDefinition) {
|
||||
if ($node instanceof FragmentDefinitionNode) {
|
||||
$this->fragments[$node->name->value] = $node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFragment(FragmentSpread $fragmentSpread)
|
||||
protected function getFragment(FragmentSpreadNode $fragmentSpread)
|
||||
{
|
||||
$spreadName = $fragmentSpread->name->value;
|
||||
$fragments = $this->getFragments();
|
||||
@ -87,13 +87,13 @@ abstract class AbstractQuerySecurity
|
||||
*
|
||||
* @param ValidationContext $context
|
||||
* @param Type|null $parentType
|
||||
* @param SelectionSet $selectionSet
|
||||
* @param SelectionSetNode $selectionSet
|
||||
* @param \ArrayObject $visitedFragmentNames
|
||||
* @param \ArrayObject $astAndDefs
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
protected function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSet $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
|
||||
protected function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSetNode $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
|
||||
{
|
||||
$_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject();
|
||||
$_astAndDefs = $astAndDefs ?: new \ArrayObject();
|
||||
@ -101,7 +101,7 @@ abstract class AbstractQuerySecurity
|
||||
foreach ($selectionSet->selections as $selection) {
|
||||
switch ($selection->kind) {
|
||||
case NodeType::FIELD:
|
||||
/* @var Field $selection */
|
||||
/* @var FieldNode $selection */
|
||||
$fieldName = $selection->name->value;
|
||||
$fieldDef = null;
|
||||
if ($parentType && method_exists($parentType, 'getFields')) {
|
||||
@ -128,7 +128,7 @@ abstract class AbstractQuerySecurity
|
||||
$_astAndDefs[$responseName][] = [$selection, $fieldDef];
|
||||
break;
|
||||
case NodeType::INLINE_FRAGMENT:
|
||||
/* @var InlineFragment $selection */
|
||||
/* @var InlineFragmentNode $selection */
|
||||
$_astAndDefs = $this->collectFieldASTsAndDefs(
|
||||
$context,
|
||||
TypeInfo::typeFromAST($context->getSchema(), $selection->typeCondition),
|
||||
@ -138,7 +138,7 @@ abstract class AbstractQuerySecurity
|
||||
);
|
||||
break;
|
||||
case NodeType::FRAGMENT_SPREAD:
|
||||
/* @var FragmentSpread $selection */
|
||||
/* @var FragmentSpreadNode $selection */
|
||||
$fragName = $selection->name->value;
|
||||
|
||||
if (empty($_visitedFragmentNames[$fragName])) {
|
||||
@ -162,7 +162,7 @@ abstract class AbstractQuerySecurity
|
||||
return $_astAndDefs;
|
||||
}
|
||||
|
||||
protected function getFieldName(Field $node)
|
||||
protected function getFieldName(FieldNode $node)
|
||||
{
|
||||
$fieldName = $node->name->value;
|
||||
$responseName = $node->alias ? $node->alias->value : $fieldName;
|
||||
|
@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Printer;
|
||||
@ -26,7 +26,7 @@ class ArgumentsOfCorrectType
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::ARGUMENT => function(Argument $argAST) use ($context) {
|
||||
NodeType::ARGUMENT => function(ArgumentNode $argAST) use ($context) {
|
||||
$argDef = $context->getArgument();
|
||||
if ($argDef) {
|
||||
$errors = DocumentValidator::isValidLiteralValue($argDef->getType(), $argAST->value);
|
||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Type\Definition\NonNull;
|
||||
@ -30,7 +30,7 @@ class DefaultValuesOfCorrectType
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $varDefAST) use ($context) {
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $varDefAST) use ($context) {
|
||||
$name = $varDefAST->variable->name->value;
|
||||
$defaultValue = $varDefAST->defaultValue;
|
||||
$type = $context->getInputType();
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Schema;
|
||||
@ -37,7 +37,7 @@ class FieldsOnCorrectType
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::FIELD => function(Field $node) use ($context) {
|
||||
NodeType::FIELD => function(FieldNode $node) use ($context) {
|
||||
$type = $context->getParentType();
|
||||
if ($type) {
|
||||
$fieldDef = $context->getFieldDef();
|
||||
|
@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\InlineFragmentNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Printer;
|
||||
@ -28,7 +28,7 @@ class FragmentsOnCompositeTypes
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) use ($context) {
|
||||
NodeType::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(FragmentDefinition $node) use ($context) {
|
||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
|
||||
$type = $context->getType();
|
||||
|
||||
if ($type && !Type::isCompositeType($type)) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Utils;
|
||||
@ -25,7 +25,7 @@ class KnownArgumentNames
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::ARGUMENT => function(Argument $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||
NodeType::ARGUMENT => function(ArgumentNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||
$argumentOf = $ancestors[count($ancestors) - 1];
|
||||
if ($argumentOf->kind === NodeType::FIELD) {
|
||||
$fieldDef = $context->getFieldDef();
|
||||
|
@ -3,14 +3,14 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
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\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Validator\Messages;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
use GraphQL\Type\Definition\Directive as DirectiveDef;
|
||||
@ -30,7 +30,7 @@ class KnownDirectives
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::DIRECTIVE => function (Directive $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||
NodeType::DIRECTIVE => function (DirectiveNode $node, $key, $parent, $path, $ancestors) use ($context) {
|
||||
$directiveDef = null;
|
||||
foreach ($context->getSchema()->getDirectives() as $def) {
|
||||
if ($def->name === $node->name->value) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
@ -18,7 +18,7 @@ class KnownFragmentNames
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) use ($context) {
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
||||
$fragmentName = $node->name->value;
|
||||
$fragment = $context->getFragment($fragmentName);
|
||||
if (!$fragment) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\NamedType;
|
||||
use GraphQL\Language\AST\NamedTypeNode;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
@ -25,7 +25,7 @@ class KnownTypeNames
|
||||
NodeType::UNION_TYPE_DEFINITION => $skip,
|
||||
NodeType::INPUT_OBJECT_TYPE_DEFINITION => $skip,
|
||||
|
||||
NodeType::NAMED_TYPE => function(NamedType $node, $key) use ($context) {
|
||||
NodeType::NAMED_TYPE => function(NamedTypeNode $node, $key) use ($context) {
|
||||
$typeName = $node->name->value;
|
||||
$type = $context->getSchema()->getType($typeName);
|
||||
if (!$type) {
|
||||
|
@ -2,10 +2,10 @@
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Document;
|
||||
use GraphQL\Language\AST\DocumentNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Utils;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
@ -26,7 +26,7 @@ class LoneAnonymousOperation
|
||||
{
|
||||
$operationCount = 0;
|
||||
return [
|
||||
NodeType::DOCUMENT => function(Document $node) use (&$operationCount) {
|
||||
NodeType::DOCUMENT => function(DocumentNode $node) use (&$operationCount) {
|
||||
$tmp = Utils::filter(
|
||||
$node->definitions,
|
||||
function ($definition) {
|
||||
@ -35,7 +35,7 @@ class LoneAnonymousOperation
|
||||
);
|
||||
$operationCount = count($tmp);
|
||||
},
|
||||
NodeType::OPERATION_DEFINITION => function(OperationDefinition $node) use (&$operationCount, $context) {
|
||||
NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use (&$operationCount, $context) {
|
||||
if (!$node->name && $operationCount > 1) {
|
||||
$context->reportError(
|
||||
new Error(self::anonOperationNotAloneMessage(), [$node])
|
||||
|
@ -10,8 +10,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
@ -48,7 +48,7 @@ class NoFragmentCycles
|
||||
NodeType::OPERATION_DEFINITION => function () {
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinition $node) use ($context) {
|
||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
||||
if (!isset($this->visitedFrags[$node->name->value])) {
|
||||
$this->detectCycleRecursive($node, $context);
|
||||
}
|
||||
@ -57,7 +57,7 @@ class NoFragmentCycles
|
||||
];
|
||||
}
|
||||
|
||||
private function detectCycleRecursive(FragmentDefinition $fragment, ValidationContext $context)
|
||||
private function detectCycleRecursive(FragmentDefinitionNode $fragment, ValidationContext $context)
|
||||
{
|
||||
$fragmentName = $fragment->name->value;
|
||||
$this->visitedFrags[$fragmentName] = true;
|
||||
|
@ -3,13 +3,13 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\Variable;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Validator\Messages;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
@ -40,7 +40,7 @@ class NoUndefinedVariables
|
||||
'enter' => function() use (&$variableNameDefined) {
|
||||
$variableNameDefined = [];
|
||||
},
|
||||
'leave' => function(OperationDefinition $operation) use (&$variableNameDefined, $context) {
|
||||
'leave' => function(OperationDefinitionNode $operation) use (&$variableNameDefined, $context) {
|
||||
$usages = $context->getRecursiveVariableUsages($operation);
|
||||
|
||||
foreach ($usages as $usage) {
|
||||
@ -59,7 +59,7 @@ class NoUndefinedVariables
|
||||
}
|
||||
}
|
||||
],
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $def) use (&$variableNameDefined) {
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $def) use (&$variableNameDefined) {
|
||||
$variableNameDefined[$def->variable->name->value] = true;
|
||||
}
|
||||
];
|
||||
|
@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
@ -32,7 +32,7 @@ class NoUnusedFragments
|
||||
$this->operationDefs[] = $node;
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinition $def) {
|
||||
NodeType::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $def) {
|
||||
$this->fragmentDefs[] = $def;
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\AST\OperationDefinition;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Validator\Messages;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
@ -30,7 +30,7 @@ class NoUnusedVariables
|
||||
'enter' => function() {
|
||||
$this->variableDefs = [];
|
||||
},
|
||||
'leave' => function(OperationDefinition $operation) use ($context) {
|
||||
'leave' => function(OperationDefinitionNode $operation) use ($context) {
|
||||
$variableNameUsed = [];
|
||||
$usages = $context->getRecursiveVariableUsages($operation);
|
||||
$opName = $operation->name ? $operation->name->value : null;
|
||||
|
@ -3,14 +3,14 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\NamedType;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
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\SelectionSet;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Type\Definition\ListOfType;
|
||||
use GraphQL\Type\Definition\NonNull;
|
||||
@ -56,7 +56,7 @@ class OverlappingFieldsCanBeMerged
|
||||
NodeType::SELECTION_SET => [
|
||||
// Note: we validate on the reverse traversal so deeper conflicts will be
|
||||
// caught first, for clearer error messages.
|
||||
'leave' => function(SelectionSet $selectionSet) use ($context) {
|
||||
'leave' => function(SelectionSetNode $selectionSet) use ($context) {
|
||||
$fieldMap = $this->collectFieldASTsAndDefs(
|
||||
$context,
|
||||
$context->getParentType(),
|
||||
@ -110,8 +110,8 @@ class OverlappingFieldsCanBeMerged
|
||||
/**
|
||||
* @param $parentFieldsAreMutuallyExclusive
|
||||
* @param $responseName
|
||||
* @param [Field, GraphQLFieldDefinition] $pair1
|
||||
* @param [Field, GraphQLFieldDefinition] $pair2
|
||||
* @param [FieldNode, GraphQLFieldDefinition] $pair1
|
||||
* @param [FieldNode, GraphQLFieldDefinition] $pair2
|
||||
* @param ValidationContext $context
|
||||
* @return array|null
|
||||
*/
|
||||
@ -206,9 +206,9 @@ class OverlappingFieldsCanBeMerged
|
||||
}
|
||||
|
||||
private function getSubfieldMap(
|
||||
Field $ast1,
|
||||
FieldNode $ast1,
|
||||
$type1,
|
||||
Field $ast2,
|
||||
FieldNode $ast2,
|
||||
$type2,
|
||||
ValidationContext $context
|
||||
) {
|
||||
@ -236,8 +236,8 @@ class OverlappingFieldsCanBeMerged
|
||||
private function subfieldConflicts(
|
||||
array $conflicts,
|
||||
$responseName,
|
||||
Field $ast1,
|
||||
Field $ast2
|
||||
FieldNode $ast1,
|
||||
FieldNode $ast2
|
||||
)
|
||||
{
|
||||
if (!empty($conflicts)) {
|
||||
@ -303,12 +303,12 @@ class OverlappingFieldsCanBeMerged
|
||||
*
|
||||
* @param ValidationContext $context
|
||||
* @param mixed $parentType
|
||||
* @param SelectionSet $selectionSet
|
||||
* @param SelectionSetNode $selectionSet
|
||||
* @param \ArrayObject $visitedFragmentNames
|
||||
* @param \ArrayObject $astAndDefs
|
||||
* @return mixed
|
||||
*/
|
||||
private function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSet $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
|
||||
private function collectFieldASTsAndDefs(ValidationContext $context, $parentType, SelectionSetNode $selectionSet, \ArrayObject $visitedFragmentNames = null, \ArrayObject $astAndDefs = null)
|
||||
{
|
||||
$_visitedFragmentNames = $visitedFragmentNames ?: new \ArrayObject();
|
||||
$_astAndDefs = $astAndDefs ?: new \ArrayObject();
|
||||
@ -348,7 +348,7 @@ class OverlappingFieldsCanBeMerged
|
||||
);
|
||||
break;
|
||||
case NodeType::FRAGMENT_SPREAD:
|
||||
/** @var FragmentSpread $selection */
|
||||
/** @var FragmentSpreadNode $selection */
|
||||
$fragName = $selection->name->value;
|
||||
if (!empty($_visitedFragmentNames[$fragName])) {
|
||||
continue;
|
||||
@ -373,8 +373,8 @@ class OverlappingFieldsCanBeMerged
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Array<Argument | Directive> $pairs1
|
||||
* @param Array<Argument | Directive> $pairs2
|
||||
* @param Array<ArgumentNode | DirectiveNode> $pairs1
|
||||
* @param Array<ArgumentNode | DirectiveNode> $pairs2
|
||||
* @return bool|string
|
||||
*/
|
||||
private function sameArguments(array $arguments1, array $arguments2)
|
||||
|
@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
||||
use GraphQL\Language\AST\InlineFragmentNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Utils;
|
||||
@ -26,7 +26,7 @@ class PossibleFragmentSpreads
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::INLINE_FRAGMENT => function(InlineFragment $node) use ($context) {
|
||||
NodeType::INLINE_FRAGMENT => function(InlineFragmentNode $node) use ($context) {
|
||||
$fragType = $context->getType();
|
||||
$parentType = $context->getParentType();
|
||||
|
||||
@ -37,7 +37,7 @@ class PossibleFragmentSpreads
|
||||
));
|
||||
}
|
||||
},
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpread $node) use ($context) {
|
||||
NodeType::FRAGMENT_SPREAD => function(FragmentSpreadNode $node) use ($context) {
|
||||
$fragName = $node->name->value;
|
||||
$fragType = $this->getFragmentType($context, $fragName);
|
||||
$parentType = $context->getParentType();
|
||||
|
@ -3,8 +3,8 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
@ -28,7 +28,7 @@ class ProvidedNonNullArguments
|
||||
{
|
||||
return [
|
||||
NodeType::FIELD => [
|
||||
'leave' => function(Field $fieldAST) use ($context) {
|
||||
'leave' => function(FieldNode $fieldAST) use ($context) {
|
||||
$fieldDef = $context->getFieldDef();
|
||||
|
||||
if (!$fieldDef) {
|
||||
@ -52,7 +52,7 @@ class ProvidedNonNullArguments
|
||||
}
|
||||
],
|
||||
NodeType::DIRECTIVE => [
|
||||
'leave' => function(Directive $directiveAST) use ($context) {
|
||||
'leave' => function(DirectiveNode $directiveAST) use ($context) {
|
||||
$directiveDef = $context->getDirective();
|
||||
if (!$directiveDef) {
|
||||
return Visitor::skipNode();
|
||||
|
@ -4,13 +4,13 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Executor\Values;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
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\OperationDefinition;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Type\Definition\FieldDefinition;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
@ -78,7 +78,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
return $this->invokeIfNeeded(
|
||||
$context,
|
||||
[
|
||||
NodeType::SELECTION_SET => function (SelectionSet $selectionSet) use ($context) {
|
||||
NodeType::SELECTION_SET => function (SelectionSetNode $selectionSet) use ($context) {
|
||||
$this->fieldAstAndDefs = $this->collectFieldASTsAndDefs(
|
||||
$context,
|
||||
$context->getParentType(),
|
||||
@ -92,7 +92,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeType::OPERATION_DEFINITION => [
|
||||
'leave' => function (OperationDefinition $operationDefinition) use ($context, &$complexity) {
|
||||
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context, &$complexity) {
|
||||
$complexity = $this->fieldComplexity($operationDefinition, $complexity);
|
||||
|
||||
if ($complexity > $this->getMaxQueryComplexity()) {
|
||||
@ -108,7 +108,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
|
||||
private function fieldComplexity($node, $complexity = 0)
|
||||
{
|
||||
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSet) {
|
||||
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSetNode) {
|
||||
foreach ($node->selectionSet->selections as $childNode) {
|
||||
$complexity = $this->nodeComplexity($childNode, $complexity);
|
||||
}
|
||||
@ -121,7 +121,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
{
|
||||
switch ($node->kind) {
|
||||
case NodeType::FIELD:
|
||||
/* @var Field $node */
|
||||
/* @var FieldNode $node */
|
||||
// default values
|
||||
$args = [];
|
||||
$complexityFn = FieldDefinition::DEFAULT_COMPLEXITY_FN;
|
||||
@ -149,7 +149,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
break;
|
||||
|
||||
case NodeType::INLINE_FRAGMENT:
|
||||
/* @var InlineFragment $node */
|
||||
/* @var InlineFragmentNode $node */
|
||||
// node has children?
|
||||
if (isset($node->selectionSet)) {
|
||||
$complexity = $this->fieldComplexity($node, $complexity);
|
||||
@ -157,7 +157,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
break;
|
||||
|
||||
case NodeType::FRAGMENT_SPREAD:
|
||||
/* @var FragmentSpread $node */
|
||||
/* @var FragmentSpreadNode $node */
|
||||
$fragment = $this->getFragment($node);
|
||||
|
||||
if (null !== $fragment) {
|
||||
@ -169,7 +169,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
return $complexity;
|
||||
}
|
||||
|
||||
private function astFieldInfo(Field $field)
|
||||
private function astFieldInfo(FieldNode $field)
|
||||
{
|
||||
$fieldName = $this->getFieldName($field);
|
||||
$astFieldInfo = [null, null];
|
||||
@ -185,7 +185,7 @@ class QueryComplexity extends AbstractQuerySecurity
|
||||
return $astFieldInfo;
|
||||
}
|
||||
|
||||
private function buildFieldArguments(Field $node)
|
||||
private function buildFieldArguments(FieldNode $node)
|
||||
{
|
||||
$rawVariableValues = $this->getRawVariableValues();
|
||||
$astFieldInfo = $this->astFieldInfo($node);
|
||||
|
@ -2,13 +2,13 @@
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FragmentSpread;
|
||||
use GraphQL\Language\AST\InlineFragment;
|
||||
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\OperationDefinition;
|
||||
use GraphQL\Language\AST\SelectionSet;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
class QueryDepth extends AbstractQuerySecurity
|
||||
@ -51,7 +51,7 @@ class QueryDepth extends AbstractQuerySecurity
|
||||
$context,
|
||||
[
|
||||
NodeType::OPERATION_DEFINITION => [
|
||||
'leave' => function (OperationDefinition $operationDefinition) use ($context) {
|
||||
'leave' => function (OperationDefinitionNode $operationDefinition) use ($context) {
|
||||
$maxDepth = $this->fieldDepth($operationDefinition);
|
||||
|
||||
if ($maxDepth > $this->getMaxQueryDepth()) {
|
||||
@ -72,7 +72,7 @@ class QueryDepth extends AbstractQuerySecurity
|
||||
|
||||
private function fieldDepth($node, $depth = 0, $maxDepth = 0)
|
||||
{
|
||||
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSet) {
|
||||
if (isset($node->selectionSet) && $node->selectionSet instanceof SelectionSetNode) {
|
||||
foreach ($node->selectionSet->selections as $childNode) {
|
||||
$maxDepth = $this->nodeDepth($childNode, $depth, $maxDepth);
|
||||
}
|
||||
@ -85,7 +85,7 @@ class QueryDepth extends AbstractQuerySecurity
|
||||
{
|
||||
switch ($node->kind) {
|
||||
case NodeType::FIELD:
|
||||
/* @var Field $node */
|
||||
/* @var FieldNode $node */
|
||||
// node has children?
|
||||
if (null !== $node->selectionSet) {
|
||||
// update maxDepth if needed
|
||||
@ -97,7 +97,7 @@ class QueryDepth extends AbstractQuerySecurity
|
||||
break;
|
||||
|
||||
case NodeType::INLINE_FRAGMENT:
|
||||
/* @var InlineFragment $node */
|
||||
/* @var InlineFragmentNode $node */
|
||||
// node has children?
|
||||
if (null !== $node->selectionSet) {
|
||||
$maxDepth = $this->fieldDepth($node, $depth, $maxDepth);
|
||||
@ -105,7 +105,7 @@ class QueryDepth extends AbstractQuerySecurity
|
||||
break;
|
||||
|
||||
case NodeType::FRAGMENT_SPREAD:
|
||||
/* @var FragmentSpread $node */
|
||||
/* @var FragmentSpreadNode $node */
|
||||
$fragment = $this->getFragment($node);
|
||||
|
||||
if (null !== $fragment) {
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Validator\Rules;
|
||||
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Field;
|
||||
use GraphQL\Language\AST\FieldNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
@ -25,7 +25,7 @@ class ScalarLeafs
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::FIELD => function(Field $node) use ($context) {
|
||||
NodeType::FIELD => function(FieldNode $node) use ($context) {
|
||||
$type = $context->getType();
|
||||
if ($type) {
|
||||
if (Type::isLeafType($type)) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
@ -28,7 +28,7 @@ class UniqueArgumentNames
|
||||
NodeType::DIRECTIVE => function () {
|
||||
$this->knownArgNames = [];
|
||||
},
|
||||
NodeType::ARGUMENT => function (Argument $node) use ($context) {
|
||||
NodeType::ARGUMENT => function (ArgumentNode $node) use ($context) {
|
||||
$argName = $node->name->value;
|
||||
if (!empty($this->knownArgNames[$argName])) {
|
||||
$context->reportError(new Error(
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Directive;
|
||||
use GraphQL\Language\AST\DirectiveNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
@ -20,7 +20,7 @@ class UniqueDirectivesPerLocation
|
||||
if (isset($node->directives)) {
|
||||
$knownDirectives = [];
|
||||
foreach ($node->directives as $directive) {
|
||||
/** @var Directive $directive */
|
||||
/** @var DirectiveNode $directive */
|
||||
$directiveName = $directive->name->value;
|
||||
if (isset($knownDirectives[$directiveName])) {
|
||||
$context->reportError(new Error(
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace GraphQL\Validator\Rules;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Argument;
|
||||
use GraphQL\Language\AST\FragmentDefinition;
|
||||
use GraphQL\Language\AST\ArgumentNode;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\Visitor;
|
||||
@ -26,7 +26,7 @@ class UniqueFragmentNames
|
||||
NodeType::OPERATION_DEFINITION => function () {
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinition $node) use ($context) {
|
||||
NodeType::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
||||
$fragmentName = $node->name->value;
|
||||
if (!empty($this->knownFragmentNames[$fragmentName])) {
|
||||
$context->reportError(new Error(
|
||||
|
@ -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\ObjectField;
|
||||
use GraphQL\Language\AST\ObjectFieldNode;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
@ -33,7 +33,7 @@ class UniqueInputFieldNames
|
||||
$this->knownNames = array_pop($this->knownNameStack);
|
||||
}
|
||||
],
|
||||
NodeType::OBJECT_FIELD => function(ObjectField $node) use ($context) {
|
||||
NodeType::OBJECT_FIELD => function(ObjectFieldNode $node) use ($context) {
|
||||
$fieldName = $node->name->value;
|
||||
|
||||
if (!empty($this->knownNames[$fieldName])) {
|
||||
|
@ -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\OperationDefinition;
|
||||
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(OperationDefinition $node) use ($context) {
|
||||
NodeType::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) {
|
||||
$operationName = $node->name;
|
||||
|
||||
if ($operationName) {
|
||||
|
@ -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\VariableDefinition;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
class UniqueVariableNames
|
||||
@ -24,7 +24,7 @@ class UniqueVariableNames
|
||||
NodeType::OPERATION_DEFINITION => function() {
|
||||
$this->knownVariableNames = [];
|
||||
},
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) use ($context) {
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinitionNode $node) use ($context) {
|
||||
$variableName = $node->variable->name->value;
|
||||
if (!empty($this->knownVariableNames[$variableName])) {
|
||||
$context->reportError(new Error(
|
||||
|
@ -5,7 +5,7 @@ namespace GraphQL\Validator\Rules;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeType;
|
||||
use GraphQL\Language\AST\VariableDefinition;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Type\Definition\InputType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
@ -22,7 +22,7 @@ class VariablesAreInputTypes
|
||||
public function __invoke(ValidationContext $context)
|
||||
{
|
||||
return [
|
||||
NodeType::VARIABLE_DEFINITION => function(VariableDefinition $node) use ($context) {
|
||||
NodeType::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.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user