This commit is contained in:
Kilian Hofmann
2021-06-01 19:56:34 +02:00
parent e74df463f2
commit 499abe195e
284 changed files with 55166 additions and 0 deletions
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ArgumentNode extends Node
{
/** @var string */
public $kind = NodeKind::ARGUMENT;
/** @var ValueNode */
public $value;
/** @var NameNode */
public $name;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class BooleanValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::BOOLEAN;
/** @var bool */
public $value;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type DefinitionNode =
* | ExecutableDefinitionNode
* | TypeSystemDefinitionNode; // experimental non-spec addition.
*/
interface DefinitionNode
{
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class DirectiveDefinitionNode extends Node implements TypeSystemDefinitionNode
{
/** @var string */
public $kind = NodeKind::DIRECTIVE_DEFINITION;
/** @var NameNode */
public $name;
/** @var ArgumentNode[] */
public $arguments;
/** @var NameNode[] */
public $locations;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class DirectiveNode extends Node
{
/** @var string */
public $kind = NodeKind::DIRECTIVE;
/** @var NameNode */
public $name;
/** @var ArgumentNode[] */
public $arguments;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class DocumentNode extends Node
{
/** @var string */
public $kind = NodeKind::DOCUMENT;
/** @var NodeList|DefinitionNode[] */
public $definitions;
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class EnumTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::ENUM_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[] */
public $directives;
/** @var EnumValueDefinitionNode[]|NodeList|null */
public $values;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class EnumTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::ENUM_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var EnumValueDefinitionNode[]|null */
public $values;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class EnumValueDefinitionNode extends Node
{
/** @var string */
public $kind = NodeKind::ENUM_VALUE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[] */
public $directives;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class EnumValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::ENUM;
/** @var string */
public $value;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type ExecutableDefinitionNode =
* | OperationDefinitionNode
* | FragmentDefinitionNode;
*/
interface ExecutableDefinitionNode extends DefinitionNode
{
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class FieldDefinitionNode extends Node
{
/** @var string */
public $kind = NodeKind::FIELD_DEFINITION;
/** @var NameNode */
public $name;
/** @var InputValueDefinitionNode[]|NodeList */
public $arguments;
/** @var TypeNode */
public $type;
/** @var DirectiveNode[]|NodeList */
public $directives;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class FieldNode extends Node implements SelectionNode
{
/** @var string */
public $kind = NodeKind::FIELD;
/** @var NameNode */
public $name;
/** @var NameNode|null */
public $alias;
/** @var ArgumentNode[]|null */
public $arguments;
/** @var DirectiveNode[]|null */
public $directives;
/** @var SelectionSetNode|null */
public $selectionSet;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class FloatValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::FLOAT;
/** @var string */
public $value;
}
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class FragmentDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
{
/** @var string */
public $kind = NodeKind::FRAGMENT_DEFINITION;
/** @var NameNode */
public $name;
/**
* Note: fragment variable definitions are experimental and may be changed
* or removed in the future.
*
* @var VariableDefinitionNode[]|NodeList
*/
public $variableDefinitions;
/** @var NamedTypeNode */
public $typeCondition;
/** @var DirectiveNode[]|NodeList */
public $directives;
/** @var SelectionSetNode */
public $selectionSet;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class FragmentSpreadNode extends Node implements SelectionNode
{
/** @var string */
public $kind = NodeKind::FRAGMENT_SPREAD;
/** @var NameNode */
public $name;
/** @var DirectiveNode[] */
public $directives;
}
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
interface HasSelectionSet
{
/**
* export type DefinitionNode = OperationDefinitionNode
* | FragmentDefinitionNode
*/
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InlineFragmentNode extends Node implements SelectionNode
{
/** @var string */
public $kind = NodeKind::INLINE_FRAGMENT;
/** @var NamedTypeNode */
public $typeCondition;
/** @var DirectiveNode[]|null */
public $directives;
/** @var SelectionSetNode */
public $selectionSet;
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InputObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::INPUT_OBJECT_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var InputValueDefinitionNode[]|null */
public $fields;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InputObjectTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::INPUT_OBJECT_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var InputValueDefinitionNode[]|null */
public $fields;
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InputValueDefinitionNode extends Node
{
/** @var string */
public $kind = NodeKind::INPUT_VALUE_DEFINITION;
/** @var NameNode */
public $name;
/** @var TypeNode */
public $type;
/** @var ValueNode */
public $defaultValue;
/** @var DirectiveNode[] */
public $directives;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class IntValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::INT;
/** @var string */
public $value;
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InterfaceTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::INTERFACE_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var FieldDefinitionNode[]|null */
public $fields;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class InterfaceTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::INTERFACE_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var FieldDefinitionNode[]|null */
public $fields;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ListTypeNode extends Node implements TypeNode
{
/** @var string */
public $kind = NodeKind::LIST_TYPE;
/** @var Node */
public $type;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ListValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::LST;
/** @var ValueNode[]|NodeList */
public $values;
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
use GraphQL\Language\Source;
use GraphQL\Language\Token;
/**
* Contains a range of UTF-8 character offsets and token references that
* identify the region of the source from which the AST derived.
*/
class Location
{
/**
* The character offset at which this Node begins.
*
* @var int
*/
public $start;
/**
* The character offset at which this Node ends.
*
* @var int
*/
public $end;
/**
* The Token at which this Node begins.
*
* @var Token
*/
public $startToken;
/**
* The Token at which this Node ends.
*
* @var Token
*/
public $endToken;
/**
* The Source document the AST represents.
*
* @var Source|null
*/
public $source;
/**
* @param int $start
* @param int $end
*
* @return static
*/
public static function create($start, $end)
{
$tmp = new static();
$tmp->start = $start;
$tmp->end = $end;
return $tmp;
}
public function __construct(?Token $startToken = null, ?Token $endToken = null, ?Source $source = null)
{
$this->startToken = $startToken;
$this->endToken = $endToken;
$this->source = $source;
if (! $startToken || ! $endToken) {
return;
}
$this->start = $startToken->start;
$this->end = $endToken->end;
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class NameNode extends Node implements TypeNode
{
/** @var string */
public $kind = NodeKind::NAME;
/** @var string */
public $value;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class NamedTypeNode extends Node implements TypeNode
{
/** @var string */
public $kind = NodeKind::NAMED_TYPE;
/** @var NameNode */
public $name;
}
+162
View File
@@ -0,0 +1,162 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
use GraphQL\Utils\Utils;
use function get_object_vars;
use function is_array;
use function is_scalar;
use function json_encode;
/**
* type Node = NameNode
* | DocumentNode
* | OperationDefinitionNode
* | VariableDefinitionNode
* | VariableNode
* | SelectionSetNode
* | FieldNode
* | ArgumentNode
* | FragmentSpreadNode
* | InlineFragmentNode
* | FragmentDefinitionNode
* | IntValueNode
* | FloatValueNode
* | StringValueNode
* | BooleanValueNode
* | EnumValueNode
* | ListValueNode
* | ObjectValueNode
* | ObjectFieldNode
* | DirectiveNode
* | ListTypeNode
* | NonNullTypeNode
*/
abstract class Node
{
/** @var Location */
public $loc;
/**
* @param (NameNode|NodeList|SelectionSetNode|Location|string|int|bool|float|null)[] $vars
*/
public function __construct(array $vars)
{
if (empty($vars)) {
return;
}
Utils::assign($this, $vars);
}
/**
* @return self
*/
public function cloneDeep()
{
return $this->cloneValue($this);
}
/**
* @param string|NodeList|Location|Node|(Node|NodeList|Location)[] $value
*
* @return string|NodeList|Location|Node
*/
private function cloneValue($value)
{
if (is_array($value)) {
$cloned = [];
foreach ($value as $key => $arrValue) {
$cloned[$key] = $this->cloneValue($arrValue);
}
} elseif ($value instanceof self) {
$cloned = clone $value;
foreach (get_object_vars($cloned) as $prop => $propValue) {
$cloned->{$prop} = $this->cloneValue($propValue);
}
} else {
$cloned = $value;
}
return $cloned;
}
/**
* @return string
*/
public function __toString()
{
$tmp = $this->toArray(true);
return (string) json_encode($tmp);
}
/**
* @param bool $recursive
*
* @return mixed[]
*/
public function toArray($recursive = false)
{
if ($recursive) {
return $this->recursiveToArray($this);
}
$tmp = (array) $this;
if ($this->loc) {
$tmp['loc'] = [
'start' => $this->loc->start,
'end' => $this->loc->end,
];
}
return $tmp;
}
/**
* @return mixed[]
*/
private function recursiveToArray(Node $node)
{
$result = [
'kind' => $node->kind,
];
if ($node->loc) {
$result['loc'] = [
'start' => $node->loc->start,
'end' => $node->loc->end,
];
}
foreach (get_object_vars($node) as $prop => $propValue) {
if (isset($result[$prop])) {
continue;
}
if ($propValue === null) {
continue;
}
if (is_array($propValue) || $propValue instanceof NodeList) {
$tmp = [];
foreach ($propValue as $tmp1) {
$tmp[] = $tmp1 instanceof Node ? $this->recursiveToArray($tmp1) : (array) $tmp1;
}
} elseif ($propValue instanceof Node) {
$tmp = $this->recursiveToArray($propValue);
} elseif (is_scalar($propValue) || $propValue === null) {
$tmp = $propValue;
} else {
$tmp = null;
}
$result[$prop] = $tmp;
}
return $result;
}
}
+138
View File
@@ -0,0 +1,138 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class NodeKind
{
// constants from language/kinds.js:
const NAME = 'Name';
// Document
const DOCUMENT = 'Document';
const OPERATION_DEFINITION = 'OperationDefinition';
const VARIABLE_DEFINITION = 'VariableDefinition';
const VARIABLE = 'Variable';
const SELECTION_SET = 'SelectionSet';
const FIELD = 'Field';
const ARGUMENT = 'Argument';
// Fragments
const FRAGMENT_SPREAD = 'FragmentSpread';
const INLINE_FRAGMENT = 'InlineFragment';
const FRAGMENT_DEFINITION = 'FragmentDefinition';
// Values
const INT = 'IntValue';
const FLOAT = 'FloatValue';
const STRING = 'StringValue';
const BOOLEAN = 'BooleanValue';
const ENUM = 'EnumValue';
const NULL = 'NullValue';
const LST = 'ListValue';
const OBJECT = 'ObjectValue';
const OBJECT_FIELD = 'ObjectField';
// Directives
const DIRECTIVE = 'Directive';
// Types
const NAMED_TYPE = 'NamedType';
const LIST_TYPE = 'ListType';
const NON_NULL_TYPE = 'NonNullType';
// Type System Definitions
const SCHEMA_DEFINITION = 'SchemaDefinition';
const OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
// Type Definitions
const SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
const OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
const FIELD_DEFINITION = 'FieldDefinition';
const INPUT_VALUE_DEFINITION = 'InputValueDefinition';
const INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
const UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
const ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
const ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
// Type Extensions
const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';
const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';
const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';
const UNION_TYPE_EXTENSION = 'UnionTypeExtension';
const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';
const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';
// Directive Definitions
const DIRECTIVE_DEFINITION = 'DirectiveDefinition';
// Type System Extensions
const SCHEMA_EXTENSION = 'SchemaExtension';
/** @var string[] */
public static $classMap = [
self::NAME => NameNode::class,
// Document
self::DOCUMENT => DocumentNode::class,
self::OPERATION_DEFINITION => OperationDefinitionNode::class,
self::VARIABLE_DEFINITION => VariableDefinitionNode::class,
self::VARIABLE => VariableNode::class,
self::SELECTION_SET => SelectionSetNode::class,
self::FIELD => FieldNode::class,
self::ARGUMENT => ArgumentNode::class,
// Fragments
self::FRAGMENT_SPREAD => FragmentSpreadNode::class,
self::INLINE_FRAGMENT => InlineFragmentNode::class,
self::FRAGMENT_DEFINITION => FragmentDefinitionNode::class,
// Values
self::INT => IntValueNode::class,
self::FLOAT => FloatValueNode::class,
self::STRING => StringValueNode::class,
self::BOOLEAN => BooleanValueNode::class,
self::ENUM => EnumValueNode::class,
self::NULL => NullValueNode::class,
self::LST => ListValueNode::class,
self::OBJECT => ObjectValueNode::class,
self::OBJECT_FIELD => ObjectFieldNode::class,
// Directives
self::DIRECTIVE => DirectiveNode::class,
// Types
self::NAMED_TYPE => NamedTypeNode::class,
self::LIST_TYPE => ListTypeNode::class,
self::NON_NULL_TYPE => NonNullTypeNode::class,
// Type System Definitions
self::SCHEMA_DEFINITION => SchemaDefinitionNode::class,
self::OPERATION_TYPE_DEFINITION => OperationTypeDefinitionNode::class,
// Type Definitions
self::SCALAR_TYPE_DEFINITION => ScalarTypeDefinitionNode::class,
self::OBJECT_TYPE_DEFINITION => ObjectTypeDefinitionNode::class,
self::FIELD_DEFINITION => FieldDefinitionNode::class,
self::INPUT_VALUE_DEFINITION => InputValueDefinitionNode::class,
self::INTERFACE_TYPE_DEFINITION => InterfaceTypeDefinitionNode::class,
self::UNION_TYPE_DEFINITION => UnionTypeDefinitionNode::class,
self::ENUM_TYPE_DEFINITION => EnumTypeDefinitionNode::class,
self::ENUM_VALUE_DEFINITION => EnumValueDefinitionNode::class,
self::INPUT_OBJECT_TYPE_DEFINITION => InputObjectTypeDefinitionNode::class,
// Type Extensions
self::SCALAR_TYPE_EXTENSION => ScalarTypeExtensionNode::class,
self::OBJECT_TYPE_EXTENSION => ObjectTypeExtensionNode::class,
self::INTERFACE_TYPE_EXTENSION => InterfaceTypeExtensionNode::class,
self::UNION_TYPE_EXTENSION => UnionTypeExtensionNode::class,
self::ENUM_TYPE_EXTENSION => EnumTypeExtensionNode::class,
self::INPUT_OBJECT_TYPE_EXTENSION => InputObjectTypeExtensionNode::class,
// Directive Definitions
self::DIRECTIVE_DEFINITION => DirectiveDefinitionNode::class,
];
}
+129
View File
@@ -0,0 +1,129 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
use ArrayAccess;
use Countable;
use Generator;
use GraphQL\Utils\AST;
use IteratorAggregate;
use function array_merge;
use function array_splice;
use function count;
use function is_array;
class NodeList implements ArrayAccess, IteratorAggregate, Countable
{
/** @var Node[]|mixed[] */
private $nodes;
/**
* @param Node[]|mixed[] $nodes
*
* @return static
*/
public static function create(array $nodes)
{
return new static($nodes);
}
/**
* @param Node[]|mixed[] $nodes
*/
public function __construct(array $nodes)
{
$this->nodes = $nodes;
}
/**
* @param mixed $offset
*
* @return bool
*/
public function offsetExists($offset)
{
return isset($this->nodes[$offset]);
}
/**
* @param mixed $offset
*
* @return mixed
*/
public function offsetGet($offset)
{
$item = $this->nodes[$offset];
if (is_array($item) && isset($item['kind'])) {
$this->nodes[$offset] = $item = AST::fromArray($item);
}
return $item;
}
/**
* @param mixed $offset
* @param mixed $value
*/
public function offsetSet($offset, $value)
{
if (is_array($value) && isset($value['kind'])) {
$value = AST::fromArray($value);
}
$this->nodes[$offset] = $value;
}
/**
* @param mixed $offset
*/
public function offsetUnset($offset)
{
unset($this->nodes[$offset]);
}
/**
* @param int $offset
* @param int $length
* @param mixed $replacement
*
* @return NodeList
*/
public function splice($offset, $length, $replacement = null)
{
return new NodeList(array_splice($this->nodes, $offset, $length, $replacement));
}
/**
* @param NodeList|Node[] $list
*
* @return NodeList
*/
public function merge($list)
{
if ($list instanceof self) {
$list = $list->nodes;
}
return new NodeList(array_merge($this->nodes, $list));
}
/**
* @return Generator
*/
public function getIterator()
{
foreach ($this->nodes as $key => $_) {
yield $this->offsetGet($key);
}
}
/**
* @return int
*/
public function count()
{
return count($this->nodes);
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class NonNullTypeNode extends Node implements TypeNode
{
/** @var string */
public $kind = NodeKind::NON_NULL_TYPE;
/** @var NameNode | ListTypeNode */
public $type;
}
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class NullValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::NULL;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ObjectFieldNode extends Node
{
/** @var string */
public $kind = NodeKind::OBJECT_FIELD;
/** @var NameNode */
public $name;
/** @var ValueNode */
public $value;
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ObjectTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::OBJECT_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var NamedTypeNode[] */
public $interfaces = [];
/** @var DirectiveNode[]|null */
public $directives;
/** @var FieldDefinitionNode[]|null */
public $fields;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ObjectTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::OBJECT_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var NamedTypeNode[] */
public $interfaces = [];
/** @var DirectiveNode[] */
public $directives;
/** @var FieldDefinitionNode[] */
public $fields;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ObjectValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::OBJECT;
/** @var ObjectFieldNode[]|NodeList */
public $fields;
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class OperationDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
{
/** @var string */
public $kind = NodeKind::OPERATION_DEFINITION;
/** @var NameNode */
public $name;
/** @var string (oneOf 'query', 'mutation')) */
public $operation;
/** @var VariableDefinitionNode[] */
public $variableDefinitions;
/** @var DirectiveNode[] */
public $directives;
/** @var SelectionSetNode */
public $selectionSet;
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class OperationTypeDefinitionNode extends Node
{
/** @var string */
public $kind = NodeKind::OPERATION_TYPE_DEFINITION;
/**
* One of 'query' | 'mutation' | 'subscription'
*
* @var string
*/
public $operation;
/** @var NamedTypeNode */
public $type;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ScalarTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::SCALAR_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[] */
public $directives;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class ScalarTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::SCALAR_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class SchemaDefinitionNode extends Node implements TypeSystemDefinitionNode
{
/** @var string */
public $kind = NodeKind::SCHEMA_DEFINITION;
/** @var DirectiveNode[] */
public $directives;
/** @var OperationTypeDefinitionNode[] */
public $operationTypes;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class SchemaTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::SCHEMA_EXTENSION;
/** @var DirectiveNode[]|null */
public $directives;
/** @var OperationTypeDefinitionNode[]|null */
public $operationTypes;
}
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode
*/
interface SelectionNode
{
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class SelectionSetNode extends Node
{
/** @var string */
public $kind = NodeKind::SELECTION_SET;
/** @var SelectionNode[] */
public $selections;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class StringValueNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::STRING;
/** @var string */
public $value;
/** @var bool|null */
public $block;
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type TypeDefinitionNode = ScalarTypeDefinitionNode
* | ObjectTypeDefinitionNode
* | InterfaceTypeDefinitionNode
* | UnionTypeDefinitionNode
* | EnumTypeDefinitionNode
* | InputObjectTypeDefinitionNode
*/
interface TypeDefinitionNode extends TypeSystemDefinitionNode
{
}
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type TypeExtensionNode =
* | ScalarTypeExtensionNode
* | ObjectTypeExtensionNode
* | InterfaceTypeExtensionNode
* | UnionTypeExtensionNode
* | EnumTypeExtensionNode
* | InputObjectTypeExtensionNode;
*/
interface TypeExtensionNode extends TypeSystemDefinitionNode
{
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type TypeNode = NamedTypeNode
* | ListTypeNode
* | NonNullTypeNode
*/
interface TypeNode
{
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
* export type TypeSystemDefinitionNode =
* | SchemaDefinitionNode
* | TypeDefinitionNode
* | TypeExtensionNode
* | DirectiveDefinitionNode
*/
interface TypeSystemDefinitionNode extends DefinitionNode
{
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class UnionTypeDefinitionNode extends Node implements TypeDefinitionNode
{
/** @var string */
public $kind = NodeKind::UNION_TYPE_DEFINITION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[] */
public $directives;
/** @var NamedTypeNode[]|null */
public $types;
/** @var StringValueNode|null */
public $description;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class UnionTypeExtensionNode extends Node implements TypeExtensionNode
{
/** @var string */
public $kind = NodeKind::UNION_TYPE_EXTENSION;
/** @var NameNode */
public $name;
/** @var DirectiveNode[]|null */
public $directives;
/** @var NamedTypeNode[]|null */
public $types;
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
/**
export type ValueNode = VariableNode
| NullValueNode
| IntValueNode
| FloatValueNode
| StringValueNode
| BooleanValueNode
| EnumValueNode
| ListValueNode
| ObjectValueNode
*/
interface ValueNode
{
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class VariableDefinitionNode extends Node implements DefinitionNode
{
/** @var string */
public $kind = NodeKind::VARIABLE_DEFINITION;
/** @var VariableNode */
public $variable;
/** @var TypeNode */
public $type;
/** @var ValueNode|null */
public $defaultValue;
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace GraphQL\Language\AST;
class VariableNode extends Node implements ValueNode
{
/** @var string */
public $kind = NodeKind::VARIABLE;
/** @var NameNode */
public $name;
}