diff --git a/docs/executing-queries.md b/docs/executing-queries.md
index 015539f..a99bade 100644
--- a/docs/executing-queries.md
+++ b/docs/executing-queries.md
@@ -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.
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)
diff --git a/docs/type-system/scalar-types.md b/docs/type-system/scalar-types.md
index aa22a9f..f688ab0 100644
--- a/docs/type-system/scalar-types.md
+++ b/docs/type-system/scalar-types.md
@@ -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)) {
diff --git a/examples/01-blog/Blog/Type/Scalar/EmailType.php b/examples/01-blog/Blog/Type/Scalar/EmailType.php
index d7541ea..a620212 100644
--- a/examples/01-blog/Blog/Type/Scalar/EmailType.php
+++ b/examples/01-blog/Blog/Type/Scalar/EmailType.php
@@ -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)) {
diff --git a/examples/01-blog/Blog/Type/Scalar/UrlType.php b/examples/01-blog/Blog/Type/Scalar/UrlType.php
index 46c282e..f9169e2 100644
--- a/examples/01-blog/Blog/Type/Scalar/UrlType.php
+++ b/examples/01-blog/Blog/Type/Scalar/UrlType.php
@@ -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)) {
diff --git a/src/Executor/ExecutionContext.php b/src/Executor/ExecutionContext.php
index 10faeaf..1ae67e1 100644
--- a/src/Executor/ExecutionContext.php
+++ b/src/Executor/ExecutionContext.php
@@ -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
+ * @var array
*/
public $fragments;
@@ -34,7 +34,7 @@ class ExecutionContext
public $contextValue;
/**
- * @var OperationDefinition
+ * @var OperationDefinitionNode
*/
public $operation;
diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php
index 5d331db..cbe02f5 100644
--- a/src/Executor/Executor.php
+++ b/src/Executor/Executor.php
@@ -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
diff --git a/src/Executor/Values.php b/src/Executor/Values.php
index 42f4e3d..6f9ef2b 100644
--- a/src/Executor/Values.php
+++ b/src/Executor/Values.php
@@ -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)) {
diff --git a/src/GraphQL.php b/src/GraphQL.php
index 5ae8733..9e3a0f8 100644
--- a/src/GraphQL.php
+++ b/src/GraphQL.php
@@ -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');
diff --git a/src/Language/AST/Argument.php b/src/Language/AST/ArgumentNode.php
similarity index 67%
rename from src/Language/AST/Argument.php
rename to src/Language/AST/ArgumentNode.php
index e840ecc..056db12 100644
--- a/src/Language/AST/Argument.php
+++ b/src/Language/AST/ArgumentNode.php
@@ -1,17 +1,17 @@
|null
+ * @var array|null
*/
public $arguments;
/**
- * @var array|null
+ * @var array|null
*/
public $directives;
/**
- * @var SelectionSet|null
+ * @var SelectionSetNode|null
*/
public $selectionSet;
}
diff --git a/src/Language/AST/FloatValue.php b/src/Language/AST/FloatValueNode.php
similarity index 70%
rename from src/Language/AST/FloatValue.php
rename to src/Language/AST/FloatValueNode.php
index 3fa1d42..02c388c 100644
--- a/src/Language/AST/FloatValue.php
+++ b/src/Language/AST/FloatValueNode.php
@@ -1,7 +1,7 @@
+ * @var array
*/
public $directives;
/**
- * @var SelectionSet
+ * @var SelectionSetNode
*/
public $selectionSet;
}
diff --git a/src/Language/AST/FragmentSpread.php b/src/Language/AST/FragmentSpreadNode.php
similarity index 58%
rename from src/Language/AST/FragmentSpread.php
rename to src/Language/AST/FragmentSpreadNode.php
index 4b9d601..a677400 100644
--- a/src/Language/AST/FragmentSpread.php
+++ b/src/Language/AST/FragmentSpreadNode.php
@@ -1,17 +1,17 @@
+ * @var array
*/
public $directives;
}
diff --git a/src/Language/AST/HasSelectionSet.php b/src/Language/AST/HasSelectionSet.php
index 54872dd..ac90b13 100644
--- a/src/Language/AST/HasSelectionSet.php
+++ b/src/Language/AST/HasSelectionSet.php
@@ -4,7 +4,7 @@ namespace GraphQL\Language\AST;
interface HasSelectionSet
{
/**
- * export type Definition = OperationDefinition
- * | FragmentDefinition
+ * export type DefinitionNode = OperationDefinitionNode
+ * | FragmentDefinitionNode
*/
}
diff --git a/src/Language/AST/InlineFragment.php b/src/Language/AST/InlineFragmentNode.php
similarity index 58%
rename from src/Language/AST/InlineFragment.php
rename to src/Language/AST/InlineFragmentNode.php
index ba3f1c9..6430a32 100644
--- a/src/Language/AST/InlineFragment.php
+++ b/src/Language/AST/InlineFragmentNode.php
@@ -1,22 +1,22 @@
|null
+ * @var array|null
*/
public $directives;
/**
- * @var SelectionSet
+ * @var SelectionSetNode
*/
public $selectionSet;
}
diff --git a/src/Language/AST/InputObjectTypeDefinition.php b/src/Language/AST/InputObjectTypeDefinitionNode.php
similarity index 59%
rename from src/Language/AST/InputObjectTypeDefinition.php
rename to src/Language/AST/InputObjectTypeDefinitionNode.php
index 500a2a9..0c39079 100644
--- a/src/Language/AST/InputObjectTypeDefinition.php
+++ b/src/Language/AST/InputObjectTypeDefinitionNode.php
@@ -1,7 +1,7 @@
+ * @var array
*/
public $values;
}
diff --git a/src/Language/AST/Name.php b/src/Language/AST/NameNode.php
similarity index 73%
rename from src/Language/AST/Name.php
rename to src/Language/AST/NameNode.php
index d3d8b8a..c2e5504 100644
--- a/src/Language/AST/Name.php
+++ b/src/Language/AST/NameNode.php
@@ -1,7 +1,7 @@
+ * @var array
*/
public $fields;
}
diff --git a/src/Language/AST/OperationDefinition.php b/src/Language/AST/OperationDefinitionNode.php
similarity index 64%
rename from src/Language/AST/OperationDefinition.php
rename to src/Language/AST/OperationDefinitionNode.php
index 2e32df5..5613ff6 100644
--- a/src/Language/AST/OperationDefinition.php
+++ b/src/Language/AST/OperationDefinitionNode.php
@@ -1,7 +1,7 @@
+ * @var array
*/
public $variableDefinitions;
/**
- * @var array
+ * @var array
*/
public $directives;
/**
- * @var SelectionSet
+ * @var SelectionSetNode
*/
public $selectionSet;
}
diff --git a/src/Language/AST/OperationTypeDefinition.php b/src/Language/AST/OperationTypeDefinitionNode.php
similarity index 79%
rename from src/Language/AST/OperationTypeDefinition.php
rename to src/Language/AST/OperationTypeDefinitionNode.php
index d269442..5daf636 100644
--- a/src/Language/AST/OperationTypeDefinition.php
+++ b/src/Language/AST/OperationTypeDefinitionNode.php
@@ -1,7 +1,7 @@
+ * @var array
*/
public $selections;
}
diff --git a/src/Language/AST/StringValue.php b/src/Language/AST/StringValueNode.php
similarity index 70%
rename from src/Language/AST/StringValue.php
rename to src/Language/AST/StringValueNode.php
index dd5212c..77da32c 100644
--- a/src/Language/AST/StringValue.php
+++ b/src/Language/AST/StringValueNode.php
@@ -1,7 +1,7 @@
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
+ * @return array
*/
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
+ * @return array
*/
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
+ * @return array
*/
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()
{
diff --git a/src/Language/Printer.php b/src/Language/Printer.php
index 1595ae3..4267ef0 100644
--- a/src/Language/Printer.php
+++ b/src/Language/Printer.php
@@ -1,43 +1,43 @@
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, ' | ');
}
diff --git a/src/Type/Definition/BooleanType.php b/src/Type/Definition/BooleanType.php
index 38e81e3..63df5ee 100644
--- a/src/Type/Definition/BooleanType.php
+++ b/src/Type/Definition/BooleanType.php
@@ -1,7 +1,7 @@
value;
}
return null;
diff --git a/src/Type/Definition/CustomScalarType.php b/src/Type/Definition/CustomScalarType.php
index 9446b9b..4879785 100644
--- a/src/Type/Definition/CustomScalarType.php
+++ b/src/Type/Definition/CustomScalarType.php
@@ -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);
}
diff --git a/src/Type/Definition/EnumType.php b/src/Type/Definition/EnumType.php
index 2945a50..95fa8c6 100644
--- a/src/Type/Definition/EnumType.php
+++ b/src/Type/Definition/EnumType.php
@@ -1,7 +1,7 @@
getNameLookup();
if (isset($lookup[$value->value])) {
$enumValue = $lookup[$value->value];
@@ -124,7 +124,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType
}
/**
- * @return \ArrayObject
+ * @return \ArrayObject
*/
private function getNameLookup()
{
diff --git a/src/Type/Definition/FieldArgument.php b/src/Type/Definition/FieldArgument.php
index 7ce1b21..73b066f 100644
--- a/src/Type/Definition/FieldArgument.php
+++ b/src/Type/Definition/FieldArgument.php
@@ -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
{
diff --git a/src/Type/Definition/FloatType.php b/src/Type/Definition/FloatType.php
index ddc1ece..dd908cc 100644
--- a/src/Type/Definition/FloatType.php
+++ b/src/Type/Definition/FloatType.php
@@ -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;
diff --git a/src/Type/Definition/IDType.php b/src/Type/Definition/IDType.php
index d881209..b45cfeb 100644
--- a/src/Type/Definition/IDType.php
+++ b/src/Type/Definition/IDType.php
@@ -1,8 +1,8 @@
value;
}
return null;
diff --git a/src/Type/Definition/IntType.php b/src/Type/Definition/IntType.php
index 2d713e8..1ab0d8f 100644
--- a/src/Type/Definition/IntType.php
+++ b/src/Type/Definition/IntType.php
@@ -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;
diff --git a/src/Type/Definition/ResolveInfo.php b/src/Type/Definition/ResolveInfo.php
index 6c7c49e..c15b1e4 100644
--- a/src/Type/Definition/ResolveInfo.php
+++ b/src/Type/Definition/ResolveInfo.php
@@ -1,12 +1,12 @@
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);
}
diff --git a/src/Type/Definition/StringType.php b/src/Type/Definition/StringType.php
index 13ca111..d752ade 100644
--- a/src/Type/Definition/StringType.php
+++ b/src/Type/Definition/StringType.php
@@ -1,7 +1,7 @@
value;
}
return null;
diff --git a/src/Utils/AST.php b/src/Utils/AST.php
index 30183c0..23e310b 100644
--- a/src/Utils/AST.php
+++ b/src/Utils/AST.php
@@ -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));
}
}
diff --git a/src/Utils/TypeInfo.php b/src/Utils/TypeInfo.php
index 1eb4d29..7910062 100644
--- a/src/Utils/TypeInfo.php
+++ b/src/Utils/TypeInfo.php
@@ -1,12 +1,12 @@
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();
diff --git a/src/Validator/DocumentValidator.php b/src/Validator/DocumentValidator.php
index 02ee918..c40b168 100644
--- a/src/Validator/DocumentValidator.php
+++ b/src/Validator/DocumentValidator.php
@@ -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 = [];
diff --git a/src/Validator/Rules/AbstractQuerySecurity.php b/src/Validator/Rules/AbstractQuerySecurity.php
index 1d804e6..0d7212a 100644
--- a/src/Validator/Rules/AbstractQuerySecurity.php
+++ b/src/Validator/Rules/AbstractQuerySecurity.php
@@ -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;
diff --git a/src/Validator/Rules/ArgumentsOfCorrectType.php b/src/Validator/Rules/ArgumentsOfCorrectType.php
index feead4a..81058cd 100644
--- a/src/Validator/Rules/ArgumentsOfCorrectType.php
+++ b/src/Validator/Rules/ArgumentsOfCorrectType.php
@@ -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);
diff --git a/src/Validator/Rules/DefaultValuesOfCorrectType.php b/src/Validator/Rules/DefaultValuesOfCorrectType.php
index 012ff7b..e54a599 100644
--- a/src/Validator/Rules/DefaultValuesOfCorrectType.php
+++ b/src/Validator/Rules/DefaultValuesOfCorrectType.php
@@ -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();
diff --git a/src/Validator/Rules/FieldsOnCorrectType.php b/src/Validator/Rules/FieldsOnCorrectType.php
index dc30662..91327b9 100644
--- a/src/Validator/Rules/FieldsOnCorrectType.php
+++ b/src/Validator/Rules/FieldsOnCorrectType.php
@@ -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();
diff --git a/src/Validator/Rules/FragmentsOnCompositeTypes.php b/src/Validator/Rules/FragmentsOnCompositeTypes.php
index e34cd4b..ae85700 100644
--- a/src/Validator/Rules/FragmentsOnCompositeTypes.php
+++ b/src/Validator/Rules/FragmentsOnCompositeTypes.php
@@ -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)) {
diff --git a/src/Validator/Rules/KnownArgumentNames.php b/src/Validator/Rules/KnownArgumentNames.php
index d52f1a7..320da9e 100644
--- a/src/Validator/Rules/KnownArgumentNames.php
+++ b/src/Validator/Rules/KnownArgumentNames.php
@@ -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();
diff --git a/src/Validator/Rules/KnownDirectives.php b/src/Validator/Rules/KnownDirectives.php
index 1a44d28..a41c463 100644
--- a/src/Validator/Rules/KnownDirectives.php
+++ b/src/Validator/Rules/KnownDirectives.php
@@ -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) {
diff --git a/src/Validator/Rules/KnownFragmentNames.php b/src/Validator/Rules/KnownFragmentNames.php
index ca616b4..9f57826 100644
--- a/src/Validator/Rules/KnownFragmentNames.php
+++ b/src/Validator/Rules/KnownFragmentNames.php
@@ -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) {
diff --git a/src/Validator/Rules/KnownTypeNames.php b/src/Validator/Rules/KnownTypeNames.php
index db70c50..ed5bde5 100644
--- a/src/Validator/Rules/KnownTypeNames.php
+++ b/src/Validator/Rules/KnownTypeNames.php
@@ -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) {
diff --git a/src/Validator/Rules/LoneAnonymousOperation.php b/src/Validator/Rules/LoneAnonymousOperation.php
index 9c4afa5..7ef500b 100644
--- a/src/Validator/Rules/LoneAnonymousOperation.php
+++ b/src/Validator/Rules/LoneAnonymousOperation.php
@@ -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])
diff --git a/src/Validator/Rules/NoFragmentCycles.php b/src/Validator/Rules/NoFragmentCycles.php
index 6911cd8..59e22f9 100644
--- a/src/Validator/Rules/NoFragmentCycles.php
+++ b/src/Validator/Rules/NoFragmentCycles.php
@@ -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;
diff --git a/src/Validator/Rules/NoUndefinedVariables.php b/src/Validator/Rules/NoUndefinedVariables.php
index 0e6a69b..c06a325 100644
--- a/src/Validator/Rules/NoUndefinedVariables.php
+++ b/src/Validator/Rules/NoUndefinedVariables.php
@@ -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;
}
];
diff --git a/src/Validator/Rules/NoUnusedFragments.php b/src/Validator/Rules/NoUnusedFragments.php
index fe8e915..42b284f 100644
--- a/src/Validator/Rules/NoUnusedFragments.php
+++ b/src/Validator/Rules/NoUnusedFragments.php
@@ -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();
},
diff --git a/src/Validator/Rules/NoUnusedVariables.php b/src/Validator/Rules/NoUnusedVariables.php
index 3d00551..40d2f32 100644
--- a/src/Validator/Rules/NoUnusedVariables.php
+++ b/src/Validator/Rules/NoUnusedVariables.php
@@ -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;
diff --git a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php
index 4670e49..3869f24 100644
--- a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php
+++ b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php
@@ -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 $pairs1
- * @param Array $pairs2
+ * @param Array $pairs1
+ * @param Array $pairs2
* @return bool|string
*/
private function sameArguments(array $arguments1, array $arguments2)
diff --git a/src/Validator/Rules/PossibleFragmentSpreads.php b/src/Validator/Rules/PossibleFragmentSpreads.php
index f5bcb35..144d568 100644
--- a/src/Validator/Rules/PossibleFragmentSpreads.php
+++ b/src/Validator/Rules/PossibleFragmentSpreads.php
@@ -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();
diff --git a/src/Validator/Rules/ProvidedNonNullArguments.php b/src/Validator/Rules/ProvidedNonNullArguments.php
index 57fabcc..18ac869 100644
--- a/src/Validator/Rules/ProvidedNonNullArguments.php
+++ b/src/Validator/Rules/ProvidedNonNullArguments.php
@@ -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();
diff --git a/src/Validator/Rules/QueryComplexity.php b/src/Validator/Rules/QueryComplexity.php
index 5ef6055..b5c915c 100644
--- a/src/Validator/Rules/QueryComplexity.php
+++ b/src/Validator/Rules/QueryComplexity.php
@@ -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);
diff --git a/src/Validator/Rules/QueryDepth.php b/src/Validator/Rules/QueryDepth.php
index 859ec7b..f571d02 100644
--- a/src/Validator/Rules/QueryDepth.php
+++ b/src/Validator/Rules/QueryDepth.php
@@ -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) {
diff --git a/src/Validator/Rules/ScalarLeafs.php b/src/Validator/Rules/ScalarLeafs.php
index ef13f36..f46bd91 100644
--- a/src/Validator/Rules/ScalarLeafs.php
+++ b/src/Validator/Rules/ScalarLeafs.php
@@ -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)) {
diff --git a/src/Validator/Rules/UniqueArgumentNames.php b/src/Validator/Rules/UniqueArgumentNames.php
index bc78f72..cee0d04 100644
--- a/src/Validator/Rules/UniqueArgumentNames.php
+++ b/src/Validator/Rules/UniqueArgumentNames.php
@@ -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(
diff --git a/src/Validator/Rules/UniqueDirectivesPerLocation.php b/src/Validator/Rules/UniqueDirectivesPerLocation.php
index 297e4f2..f389b12 100644
--- a/src/Validator/Rules/UniqueDirectivesPerLocation.php
+++ b/src/Validator/Rules/UniqueDirectivesPerLocation.php
@@ -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(
diff --git a/src/Validator/Rules/UniqueFragmentNames.php b/src/Validator/Rules/UniqueFragmentNames.php
index 24f09f2..5cf63be 100644
--- a/src/Validator/Rules/UniqueFragmentNames.php
+++ b/src/Validator/Rules/UniqueFragmentNames.php
@@ -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(
diff --git a/src/Validator/Rules/UniqueInputFieldNames.php b/src/Validator/Rules/UniqueInputFieldNames.php
index 2b5427f..4aa3015 100644
--- a/src/Validator/Rules/UniqueInputFieldNames.php
+++ b/src/Validator/Rules/UniqueInputFieldNames.php
@@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType;
-use GraphQL\Language\AST\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])) {
diff --git a/src/Validator/Rules/UniqueOperationNames.php b/src/Validator/Rules/UniqueOperationNames.php
index 3d8c4e0..8bc9217 100644
--- a/src/Validator/Rules/UniqueOperationNames.php
+++ b/src/Validator/Rules/UniqueOperationNames.php
@@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType;
-use GraphQL\Language\AST\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) {
diff --git a/src/Validator/Rules/UniqueVariableNames.php b/src/Validator/Rules/UniqueVariableNames.php
index 2ec5201..8bb27b4 100644
--- a/src/Validator/Rules/UniqueVariableNames.php
+++ b/src/Validator/Rules/UniqueVariableNames.php
@@ -4,7 +4,7 @@ namespace GraphQL\Validator\Rules;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\NodeType;
-use GraphQL\Language\AST\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(
diff --git a/src/Validator/Rules/VariablesAreInputTypes.php b/src/Validator/Rules/VariablesAreInputTypes.php
index 0db91bc..6251ff5 100644
--- a/src/Validator/Rules/VariablesAreInputTypes.php
+++ b/src/Validator/Rules/VariablesAreInputTypes.php
@@ -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.
diff --git a/src/Validator/Rules/VariablesInAllowedPosition.php b/src/Validator/Rules/VariablesInAllowedPosition.php
index 5cef130..9cbf673 100644
--- a/src/Validator/Rules/VariablesInAllowedPosition.php
+++ b/src/Validator/Rules/VariablesInAllowedPosition.php
@@ -3,12 +3,12 @@ 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\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\Type\Definition\ListOfType;
use GraphQL\Type\Definition\NonNull;
@@ -33,7 +33,7 @@ class VariablesInAllowedPosition
'enter' => function () {
$this->varDefMap = [];
},
- 'leave' => function(OperationDefinition $operation) use ($context) {
+ 'leave' => function(OperationDefinitionNode $operation) use ($context) {
$usages = $context->getRecursiveVariableUsages($operation);
foreach ($usages as $usage) {
@@ -61,7 +61,7 @@ class VariablesInAllowedPosition
}
}
],
- NodeType::VARIABLE_DEFINITION => function (VariableDefinition $varDefAST) {
+ NodeType::VARIABLE_DEFINITION => function (VariableDefinitionNode $varDefAST) {
$this->varDefMap[$varDefAST->variable->name->value] = $varDefAST;
}
];
diff --git a/src/Validator/ValidationContext.php b/src/Validator/ValidationContext.php
index 2dd6894..c6f4d91 100644
--- a/src/Validator/ValidationContext.php
+++ b/src/Validator/ValidationContext.php
@@ -1,17 +1,17 @@
+ * @var array
*/
private $fragments;
@@ -76,10 +76,10 @@ class ValidationContext
* ValidationContext constructor.
*
* @param Schema $schema
- * @param Document $ast
+ * @param DocumentNode $ast
* @param TypeInfo $typeInfo
*/
- function __construct(Schema $schema, Document $ast, TypeInfo $typeInfo)
+ function __construct(Schema $schema, DocumentNode $ast, TypeInfo $typeInfo)
{
$this->schema = $schema;
$this->ast = $ast;
@@ -116,7 +116,7 @@ class ValidationContext
}
/**
- * @return Document
+ * @return DocumentNode
*/
function getDocument()
{
@@ -125,7 +125,7 @@ class ValidationContext
/**
* @param $name
- * @return FragmentDefinition|null
+ * @return FragmentDefinitionNode|null
*/
function getFragment($name)
{
@@ -144,7 +144,7 @@ class ValidationContext
/**
* @param HasSelectionSet $node
- * @return FragmentSpread[]
+ * @return FragmentSpreadNode[]
*/
function getFragmentSpreads(HasSelectionSet $node)
{
@@ -170,10 +170,10 @@ class ValidationContext
}
/**
- * @param OperationDefinition $operation
- * @return FragmentDefinition[]
+ * @param OperationDefinitionNode $operation
+ * @return FragmentDefinitionNode[]
*/
- function getRecursivelyReferencedFragments(OperationDefinition $operation)
+ function getRecursivelyReferencedFragments(OperationDefinitionNode $operation)
{
$fragments = isset($this->recursivelyReferencedFragments[$operation]) ? $this->recursivelyReferencedFragments[$operation] : null;
@@ -204,7 +204,7 @@ class ValidationContext
/**
* @param HasSelectionSet $node
- * @return array List of ['node' => Variable, 'type' => ?InputObjectType]
+ * @return array List of ['node' => VariableNode, 'type' => ?InputObjectType]
*/
function getVariableUsages(HasSelectionSet $node)
{
@@ -217,7 +217,7 @@ class ValidationContext
NodeType::VARIABLE_DEFINITION => function () {
return false;
},
- NodeType::VARIABLE => function (Variable $variable) use (&$newUsages, $typeInfo) {
+ NodeType::VARIABLE => function (VariableNode $variable) use (&$newUsages, $typeInfo) {
$newUsages[] = ['node' => $variable, 'type' => $typeInfo->getInputType()];
}
]));
@@ -228,10 +228,10 @@ class ValidationContext
}
/**
- * @param OperationDefinition $operation
- * @return array List of ['node' => Variable, 'type' => ?InputObjectType]
+ * @param OperationDefinitionNode $operation
+ * @return array List of ['node' => VariableNode, 'type' => ?InputObjectType]
*/
- function getRecursiveVariableUsages(OperationDefinition $operation)
+ function getRecursiveVariableUsages(OperationDefinitionNode $operation)
{
$usages = isset($this->recursiveVariableUsages[$operation]) ? $this->recursiveVariableUsages[$operation] : null;
diff --git a/tests/Language/ParserTest.php b/tests/Language/ParserTest.php
index e4caa4d..b1a1d2c 100644
--- a/tests/Language/ParserTest.php
+++ b/tests/Language/ParserTest.php
@@ -1,14 +1,14 @@
true]);
- $expected = new SelectionSet([
+ $expected = new SelectionSetNode([
'selections' => [
- new Field([
- 'name' => new Name(['value' => 'field']),
+ new FieldNode([
+ 'name' => new NameNode(['value' => 'field']),
'arguments' => [
- new Argument([
- 'name' => new Name(['value' => 'arg']),
- 'value' => new StringValue([
+ new ArgumentNode([
+ 'name' => new NameNode(['value' => 'arg']),
+ 'value' => new StringValueNode([
'value' => "Has a $char multi-byte character."
])
])
diff --git a/tests/Language/PrinterTest.php b/tests/Language/PrinterTest.php
index bf584ee..0e7e8e6 100644
--- a/tests/Language/PrinterTest.php
+++ b/tests/Language/PrinterTest.php
@@ -1,15 +1,15 @@
new Name(['value' => 'foo'])]);
+ $ast = new FieldNode(['name' => new NameNode(['value' => 'foo'])]);
$this->assertEquals('foo', Printer::doPrint($ast));
}
diff --git a/tests/Language/SchemaParserTest.php b/tests/Language/SchemaParserTest.php
index f6baf47..aaba973 100644
--- a/tests/Language/SchemaParserTest.php
+++ b/tests/Language/SchemaParserTest.php
@@ -1,25 +1,25 @@
new Name(['value' => 'foo'])
+ $ast = new ScalarTypeDefinitionNode([
+ 'name' => new NameNode(['value' => 'foo'])
]);
$this->assertEquals('scalar foo', Printer::doPrint($ast));
}
diff --git a/tests/Language/VisitorTest.php b/tests/Language/VisitorTest.php
index fd5fd33..bdf5023 100644
--- a/tests/Language/VisitorTest.php
+++ b/tests/Language/VisitorTest.php
@@ -1,13 +1,13 @@
[
- 'enter' => function(OperationDefinition $node) use (&$selectionSet) {
+ 'enter' => function(OperationDefinitionNode $node) use (&$selectionSet) {
$selectionSet = $node->selectionSet;
$newNode = clone $node;
- $newNode->selectionSet = new SelectionSet([
+ $newNode->selectionSet = new SelectionSetNode([
'selections' => []
]);
$newNode->didEnter = true;
return $newNode;
},
- 'leave' => function(OperationDefinition $node) use (&$selectionSet) {
+ 'leave' => function(OperationDefinitionNode $node) use (&$selectionSet) {
$newNode = clone $node;
$newNode->selectionSet = $selectionSet;
$newNode->didLeave = true;
@@ -65,13 +65,13 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
$editedAst = Visitor::visit($ast, [
NodeType::DOCUMENT => [
- 'enter' => function (Document $node) {
+ 'enter' => function (DocumentNode $node) {
$tmp = clone $node;
$tmp->definitions = [];
$tmp->didEnter = true;
return $tmp;
},
- 'leave' => function(Document $node) use ($definitions) {
+ 'leave' => function(DocumentNode $node) use ($definitions) {
$tmp = clone $node;
$node->definitions = $definitions;
$node->didLeave = true;
@@ -96,7 +96,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
$ast = Parser::parse('{ a, b, c { a, b, c } }', ['noLocation' => true]);
$editedAst = Visitor::visit($ast, [
'enter' => function($node) {
- if ($node instanceof Field && $node->name->value === 'b') {
+ if ($node instanceof FieldNode && $node->name->value === 'b') {
return Visitor::removeNode();
}
}
@@ -120,7 +120,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
$ast = Parser::parse('{ a, b, c { a, b, c } }', ['noLocation' => true]);
$editedAst = Visitor::visit($ast, [
'leave' => function($node) {
- if ($node instanceof Field && $node->name->value === 'b') {
+ if ($node instanceof FieldNode && $node->name->value === 'b') {
return Visitor::removeNode();
}
}
@@ -142,8 +142,8 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
*/
public function testVisitsEditedNode()
{
- $addedField = new Field(array(
- 'name' => new Name(array(
+ $addedField = new FieldNode(array(
+ 'name' => new NameNode(array(
'value' => '__typename'
))
));
@@ -154,9 +154,9 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
Visitor::visit($ast, [
'enter' => function($node) use ($addedField, &$didVisitAddedField) {
- if ($node instanceof Field && $node->name->value === 'a') {
- return new Field([
- 'selectionSet' => new SelectionSet(array(
+ if ($node instanceof FieldNode && $node->name->value === 'a') {
+ return new FieldNode([
+ 'selectionSet' => new SelectionSetNode(array(
'selections' => array_merge([$addedField], $node->selectionSet->selections)
))
]);
@@ -181,7 +181,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
Visitor::visit($ast, [
'enter' => function(Node $node) use (&$visited) {
$visited[] = ['enter', $node->kind, isset($node->value) ? $node->value : null];
- if ($node instanceof Field && $node->name->value === 'b') {
+ if ($node instanceof FieldNode && $node->name->value === 'b') {
return Visitor::skipNode();
}
},
@@ -222,7 +222,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
Visitor::visit($ast, [
'enter' => function(Node $node) use (&$visited) {
$visited[] = ['enter', $node->kind, isset($node->value) ? $node->value : null];
- if ($node instanceof Name && $node->value === 'x') {
+ if ($node instanceof NameNode && $node->value === 'x') {
return Visitor::stop();
}
},
@@ -298,14 +298,14 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
$ast = Parser::parse('{ a, b { x }, c }');
Visitor::visit($ast, [
- NodeType::NAME => function(Name $node) use (&$visited) {
+ NodeType::NAME => function(NameNode $node) use (&$visited) {
$visited[] = ['enter', $node->kind, $node->value];
},
NodeType::SELECTION_SET => [
- 'enter' => function(SelectionSet $node) use (&$visited) {
+ 'enter' => function(SelectionSetNode $node) use (&$visited) {
$visited[] = ['enter', $node->kind, null];
},
- 'leave' => function(SelectionSet $node) use (&$visited) {
+ 'leave' => function(SelectionSetNode $node) use (&$visited) {
$visited[] = ['leave', $node->kind, null];
}
]
@@ -1227,16 +1227,16 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
!$node->selectionSet &&
Type::isCompositeType(Type::getNamedType($type))
) {
- return new Field([
+ return new FieldNode([
'alias' => $node->alias,
'name' => $node->name,
'arguments' => $node->arguments,
'directives' => $node->directives,
- 'selectionSet' => new SelectionSet([
+ 'selectionSet' => new SelectionSetNode([
'kind' => 'SelectionSet',
'selections' => [
- new Field([
- 'name' => new Name(['value' => '__typename'])
+ new FieldNode([
+ 'name' => new NameNode(['value' => '__typename'])
])
]
])
diff --git a/tests/Utils/AstFromValueTest.php b/tests/Utils/AstFromValueTest.php
index 6468fb1..9cf983c 100644
--- a/tests/Utils/AstFromValueTest.php
+++ b/tests/Utils/AstFromValueTest.php
@@ -1,16 +1,16 @@
assertEquals(new BooleanValue(['value' => true]), AST::astFromValue(true, Type::boolean()));
- $this->assertEquals(new BooleanValue(['value' => false]), AST::astFromValue(false, Type::boolean()));
- $this->assertEquals(new NullValue([]), AST::astFromValue(null, Type::boolean()));
- $this->assertEquals(new BooleanValue(['value' => false]), AST::astFromValue(0, Type::boolean()));
- $this->assertEquals(new BooleanValue(['value' => true]), AST::astFromValue(1, Type::boolean()));
- $this->assertEquals(new BooleanValue(['value' => false]), AST::astFromValue(0, Type::nonNull(Type::boolean())));
+ $this->assertEquals(new BooleanValueNode(['value' => true]), AST::astFromValue(true, Type::boolean()));
+ $this->assertEquals(new BooleanValueNode(['value' => false]), AST::astFromValue(false, Type::boolean()));
+ $this->assertEquals(new NullValueNode([]), AST::astFromValue(null, Type::boolean()));
+ $this->assertEquals(new BooleanValueNode(['value' => false]), AST::astFromValue(0, Type::boolean()));
+ $this->assertEquals(new BooleanValueNode(['value' => true]), AST::astFromValue(1, Type::boolean()));
+ $this->assertEquals(new BooleanValueNode(['value' => false]), AST::astFromValue(0, Type::nonNull(Type::boolean())));
$this->assertEquals(null, AST::astFromValue(null, Type::nonNull(Type::boolean()))); // Note: null means that AST cannot
}
@@ -39,9 +39,9 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsIntValuesToASTs()
{
- $this->assertEquals(new IntValue(['value' => '123']), AST::astFromValue(123.0, Type::int()));
- $this->assertEquals(new IntValue(['value' => '123']), AST::astFromValue(123.5, Type::int()));
- $this->assertEquals(new IntValue(['value' => '10000']), AST::astFromValue(1e4, Type::int()));
+ $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123.0, Type::int()));
+ $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123.5, Type::int()));
+ $this->assertEquals(new IntValueNode(['value' => '10000']), AST::astFromValue(1e4, Type::int()));
try {
AST::astFromValue(1e40, Type::int()); // Note: js version will produce 1e+40, both values are valid GraphQL floats
@@ -56,11 +56,11 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsFloatValuesToIntOrFloatASTs()
{
- $this->assertEquals(new IntValue(['value' => '123']), AST::astFromValue(123, Type::float()));
- $this->assertEquals(new IntValue(['value' => '123']), AST::astFromValue(123.0, Type::float()));
- $this->assertEquals(new FloatValue(['value' => '123.5']), AST::astFromValue(123.5, Type::float()));
- $this->assertEquals(new IntValue(['value' => '10000']), AST::astFromValue(1e4, Type::float()));
- $this->assertEquals(new FloatValue(['value' => '1e+40']), AST::astFromValue(1e40, Type::float()));
+ $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123, Type::float()));
+ $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123.0, Type::float()));
+ $this->assertEquals(new FloatValueNode(['value' => '123.5']), AST::astFromValue(123.5, Type::float()));
+ $this->assertEquals(new IntValueNode(['value' => '10000']), AST::astFromValue(1e4, Type::float()));
+ $this->assertEquals(new FloatValueNode(['value' => '1e+40']), AST::astFromValue(1e40, Type::float()));
}
/**
@@ -68,12 +68,12 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsStringValuesToASTs()
{
- $this->assertEquals(new StringValue(['value' => 'hello']), AST::astFromValue('hello', Type::string()));
- $this->assertEquals(new StringValue(['value' => 'VALUE']), AST::astFromValue('VALUE', Type::string()));
- $this->assertEquals(new StringValue(['value' => 'VA\\nLUE']), AST::astFromValue("VA\nLUE", Type::string()));
- $this->assertEquals(new StringValue(['value' => '123']), AST::astFromValue(123, Type::string()));
- $this->assertEquals(new StringValue(['value' => 'false']), AST::astFromValue(false, Type::string()));
- $this->assertEquals(new NullValue([]), AST::astFromValue(null, Type::string()));
+ $this->assertEquals(new StringValueNode(['value' => 'hello']), AST::astFromValue('hello', Type::string()));
+ $this->assertEquals(new StringValueNode(['value' => 'VALUE']), AST::astFromValue('VALUE', Type::string()));
+ $this->assertEquals(new StringValueNode(['value' => 'VA\\nLUE']), AST::astFromValue("VA\nLUE", Type::string()));
+ $this->assertEquals(new StringValueNode(['value' => '123']), AST::astFromValue(123, Type::string()));
+ $this->assertEquals(new StringValueNode(['value' => 'false']), AST::astFromValue(false, Type::string()));
+ $this->assertEquals(new NullValueNode([]), AST::astFromValue(null, Type::string()));
$this->assertEquals(null, AST::astFromValue(null, Type::nonNull(Type::string())));
}
@@ -82,12 +82,12 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertIdValuesToIntOrStringASTs()
{
- $this->assertEquals(new StringValue(['value' => 'hello']), AST::astFromValue('hello', Type::id()));
- $this->assertEquals(new StringValue(['value' => 'VALUE']), AST::astFromValue('VALUE', Type::id()));
- $this->assertEquals(new StringValue(['value' => 'VA\\nLUE']), AST::astFromValue("VA\nLUE", Type::id()));
- $this->assertEquals(new IntValue(['value' => '123']), AST::astFromValue(123, Type::id()));
- $this->assertEquals(new StringValue(['value' => 'false']), AST::astFromValue(false, Type::id()));
- $this->assertEquals(new NullValue([]), AST::astFromValue(null, Type::id()));
+ $this->assertEquals(new StringValueNode(['value' => 'hello']), AST::astFromValue('hello', Type::id()));
+ $this->assertEquals(new StringValueNode(['value' => 'VALUE']), AST::astFromValue('VALUE', Type::id()));
+ $this->assertEquals(new StringValueNode(['value' => 'VA\\nLUE']), AST::astFromValue("VA\nLUE", Type::id()));
+ $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123, Type::id()));
+ $this->assertEquals(new StringValueNode(['value' => 'false']), AST::astFromValue(false, Type::id()));
+ $this->assertEquals(new NullValueNode([]), AST::astFromValue(null, Type::id()));
$this->assertEquals(null, AST::astFromValue(null, Type::nonNull(Type::id())));
}
@@ -104,8 +104,8 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsStringValuesToEnumASTsIfPossible()
{
- $this->assertEquals(new EnumValue(['value' => 'HELLO']), AST::astFromValue('HELLO', $this->myEnum()));
- $this->assertEquals(new EnumValue(['value' => 'COMPLEX']), AST::astFromValue($this->complexValue(), $this->myEnum()));
+ $this->assertEquals(new EnumValueNode(['value' => 'HELLO']), AST::astFromValue('HELLO', $this->myEnum()));
+ $this->assertEquals(new EnumValueNode(['value' => 'COMPLEX']), AST::astFromValue($this->complexValue(), $this->myEnum()));
// Note: case sensitive
$this->assertEquals(null, AST::astFromValue('hello', $this->myEnum()));
@@ -119,18 +119,18 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsArrayValuesToListASTs()
{
- $value1 = new ListValue([
+ $value1 = new ListValueNode([
'values' => [
- new StringValue(['value' => 'FOO']),
- new StringValue(['value' => 'BAR'])
+ new StringValueNode(['value' => 'FOO']),
+ new StringValueNode(['value' => 'BAR'])
]
]);
$this->assertEquals($value1, AST::astFromValue(['FOO', 'BAR'], Type::listOf(Type::string())));
- $value2 = new ListValue([
+ $value2 = new ListValueNode([
'values' => [
- new EnumValue(['value' => 'HELLO']),
- new EnumValue(['value' => 'GOODBYE']),
+ new EnumValueNode(['value' => 'HELLO']),
+ new EnumValueNode(['value' => 'GOODBYE']),
]
]);
$this->assertEquals($value2, AST::astFromValue(['HELLO', 'GOODBYE'], Type::listOf($this->myEnum())));
@@ -141,7 +141,7 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
*/
public function testConvertsListSingletons()
{
- $this->assertEquals(new StringValue(['value' => 'FOO']), AST::astFromValue('FOO', Type::listOf(Type::string())));
+ $this->assertEquals(new StringValueNode(['value' => 'FOO']), AST::astFromValue('FOO', Type::listOf(Type::string())));
}
/**
@@ -157,10 +157,10 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
]
]);
- $expected = new ObjectValue([
+ $expected = new ObjectValueNode([
'fields' => [
- $this->objectField('foo', new IntValue(['value' => '3'])),
- $this->objectField('bar', new EnumValue(['value' => 'HELLO']))
+ $this->objectField('foo', new IntValueNode(['value' => '3'])),
+ $this->objectField('bar', new EnumValueNode(['value' => 'HELLO']))
]
]);
@@ -169,6 +169,9 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, AST::astFromValue((object) $data, $inputObj));
}
+ /**
+ * @it converts input objects with explicit nulls
+ */
public function testConvertsInputObjectsWithExplicitNulls()
{
$inputObj = new InputObjectType([
@@ -179,32 +182,11 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
]
]);
- $this->assertEquals(new ObjectValue([
+ $this->assertEquals(new ObjectValueNode([
'fields' => [
- $this->objectField('foo', new NullValue([]))
+ $this->objectField('foo', new NullValueNode([]))
]
]), AST::astFromValue(['foo' => null], $inputObj));
-/*
- const inputObj = new GraphQLInputObjectType({
- name: 'MyInputObj',
- fields: {
- foo: { type: GraphQLFloat },
- bar: { type: myEnum },
- }
- });
-
- expect(astFromValue(
- { foo: null },
- inputObj
- )).to.deep.equal(
- { kind: 'ObjectValue',
- fields: [
- { kind: 'ObjectField',
- name: { kind: 'Name', value: 'foo' },
- value: { kind: 'NullValue' } } ] }
- );
- });
- */
}
private $complexValue;
@@ -236,12 +218,12 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
/**
* @param $name
* @param $value
- * @return ObjectField
+ * @return ObjectFieldNode
*/
private function objectField($name, $value)
{
- return new ObjectField([
- 'name' => new Name(['value' => $name]),
+ return new ObjectFieldNode([
+ 'name' => new NameNode(['value' => $name]),
'value' => $value
]);
}
diff --git a/tests/Utils/ValueFromAstTest.php b/tests/Utils/ValueFromAstTest.php
index 15799da..1bceab2 100644
--- a/tests/Utils/ValueFromAstTest.php
+++ b/tests/Utils/ValueFromAstTest.php
@@ -1,7 +1,7 @@