mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Address recent SDL spec changes
This should be the last set of spec changes for a standardized SDL ref: graphql/graphql-js#1139
This commit is contained in:
parent
50cbfb4a44
commit
6d08c342c9
@ -4,8 +4,8 @@ namespace GraphQL\Language\AST;
|
||||
interface DefinitionNode
|
||||
{
|
||||
/**
|
||||
* export type DefinitionNode = OperationDefinitionNode
|
||||
* | FragmentDefinitionNode
|
||||
* | TypeSystemDefinitionNode // experimental non-spec addition.
|
||||
* export type DefinitionNode =
|
||||
* | ExecutableDefinitionNode
|
||||
* | TypeSystemDefinitionNode; // experimental non-spec addition.
|
||||
*/
|
||||
}
|
||||
|
11
src/Language/AST/ExecutableDefinitionNode.php
Normal file
11
src/Language/AST/ExecutableDefinitionNode.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
interface ExecutableDefinitionNode extends DefinitionNode
|
||||
{
|
||||
/**
|
||||
* export type ExecutableDefinitionNode =
|
||||
* | OperationDefinitionNode
|
||||
* | FragmentDefinitionNode;
|
||||
*/
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class FragmentDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
class FragmentDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
|
||||
{
|
||||
public $kind = NodeKind::FRAGMENT_DEFINITION;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Language\AST;
|
||||
|
||||
class OperationDefinitionNode extends Node implements DefinitionNode, HasSelectionSet
|
||||
class OperationDefinitionNode extends Node implements ExecutableDefinitionNode, HasSelectionSet
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -6,6 +6,7 @@ use GraphQL\Language\AST\DirectiveDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\EnumTypeExtensionNode;
|
||||
use GraphQL\Language\AST\EnumValueDefinitionNode;
|
||||
use GraphQL\Language\AST\ExecutableDefinitionNode;
|
||||
use GraphQL\Language\AST\FieldDefinitionNode;
|
||||
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\InputObjectTypeExtensionNode;
|
||||
@ -328,24 +329,18 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OperationDefinitionNode|FragmentDefinitionNode|TypeSystemDefinitionNode
|
||||
* @return ExecutableDefinitionNode|TypeSystemDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseDefinition()
|
||||
{
|
||||
if ($this->peek(Token::BRACE_L)) {
|
||||
return $this->parseOperationDefinition();
|
||||
}
|
||||
|
||||
if ($this->peek(Token::NAME)) {
|
||||
switch ($this->lexer->token->value) {
|
||||
case 'query':
|
||||
case 'mutation':
|
||||
case 'subscription':
|
||||
return $this->parseOperationDefinition();
|
||||
|
||||
case 'fragment':
|
||||
return $this->parseFragmentDefinition();
|
||||
return $this->parseExecutableDefinition();
|
||||
|
||||
// Note: The schema definition language is an experimental addition.
|
||||
case 'schema':
|
||||
@ -357,13 +352,37 @@ class Parser
|
||||
case 'input':
|
||||
case 'extend':
|
||||
case 'directive':
|
||||
// Note: The schema definition language is an experimental addition.
|
||||
return $this->parseTypeSystemDefinition();
|
||||
}
|
||||
} else if ($this->peek(Token::BRACE_L)) {
|
||||
return $this->parseExecutableDefinition();
|
||||
} else if ($this->peekDescription()) {
|
||||
// Note: The schema definition language is an experimental addition.
|
||||
return $this->parseTypeSystemDefinition();
|
||||
}
|
||||
|
||||
// Note: The schema definition language is an experimental addition.
|
||||
if ($this->peekDescription()) {
|
||||
return $this->parseTypeSystemDefinition();
|
||||
throw $this->unexpected();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ExecutableDefinitionNode
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
function parseExecutableDefinition()
|
||||
{
|
||||
if ($this->peek(Token::NAME)) {
|
||||
switch ($this->lexer->token->value) {
|
||||
case 'query':
|
||||
case 'mutation':
|
||||
case 'subscription':
|
||||
return $this->parseOperationDefinition();
|
||||
|
||||
case 'fragment':
|
||||
return $this->parseFragmentDefinition();
|
||||
}
|
||||
} else if ($this->peek(Token::BRACE_L)) {
|
||||
return $this->parseOperationDefinition();
|
||||
}
|
||||
|
||||
throw $this->unexpected();
|
||||
|
Loading…
x
Reference in New Issue
Block a user