GraphQL\Language\Parser::parseDefinition PHP Method

parseDefinition() public method

public parseDefinition ( ) : OperationDefinitionNode | FragmentDefinitionNode | GraphQL\Language\AST\TypeSystemDefinitionNode
return GraphQL\Language\AST\OperationDefinitionNode | GraphQL\Language\AST\FragmentDefinitionNode | GraphQL\Language\AST\TypeSystemDefinitionNode
    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();
                    // Note: the Type System IDL is an experimental non-spec addition.
                // Note: the Type System IDL is an experimental non-spec addition.
                case 'schema':
                case 'scalar':
                case 'type':
                case 'interface':
                case 'union':
                case 'enum':
                case 'input':
                case 'extend':
                case 'directive':
                    return $this->parseTypeSystemDefinition();
            }
        }
        throw $this->unexpected();
    }