src/Language/Parser.php
private function parseOperationDefinition()
    {
        $start = $this->lexer->token;
        if ($this->peek(Token::BRACE_L)) {
            return new OperationDefinitionNode([
                'operation'           => 'query',
                'name'                => null,
                'variableDefinitions' => new NodeList([]),
                'directives'          => new NodeList([]),
                'selectionSet'        => $this->parseSelectionSet(),
                'loc'                 => $this->loc($start),
            ]);
        }

        $operation = $this->parseOperationType();

        $name = null;
        if ($this->peek(Token::NAME)) {
            $name = $this->parseName();
        }

        return new OperationDefinitionNode([
            'operation'           => $operation,
            'name'                => $name,
            'variableDefinitions' => $this->parseVariableDefinitions(),
            'directives'          => $this->parseDirectives(false),
            'selectionSet'        => $this->parseSelectionSet(),
            'loc'                 => $this->loc($start),
        ]);
    }
private function parseOperationDefinition()
    {
        $start = $this->lexer->token;
        if ($this->peek(Token::BRACE_L)) {
            return new OperationDefinitionNode([
                'operation'           => 'query',
                'name'                => null,
                'variableDefinitions' => new NodeList([]),
                'directives'          => new NodeList([]),
                'selectionSet'        => $this->parseSelectionSet(),
                'loc'                 => $this->loc($start),
            ]);
        }

        $operation = $this->parseOperationType();

        $name = null;
        if ($this->peek(Token::NAME)) {
            $name = $this->parseName();
        }

        return new OperationDefinitionNode([
            'operation'           => $operation,
            'name'                => $name,
            'variableDefinitions' => $this->parseVariableDefinitions(),
            'directives'          => $this->parseDirectives(false),
            'selectionSet'        => $this->parseSelectionSet(),
            'loc'                 => $this->loc($start),
        ]);
    }
private function parseOperationDefinition ( ) { $ start = $ this -> lexer -> token ; if ( $ this -> peek ( Token :: BRACE_L ) ) { return new OperationDefinitionNode ( [ 'operation' => 'query' , 'name' => null , 'variableDefinitions' => new NodeList ( [ ] ) , 'directives' => new NodeList ( [ ] ) , 'selectionSet' => $ this -> parseSelectionSet ( ) , 'loc' => $ this -> loc ( $ start ) , ] ) ; } $ operation = $ this -> parseOperationType ( ) ; $ name = null ; if ( $ this -> peek ( Token :: NAME ) ) { $ name = $ this -> parseName ( ) ; } return new OperationDefinitionNode ( [ 'operation' => $ operation , 'name' => $ name , 'variableDefinitions' => $ this -> parseVariableDefinitions ( ) , 'directives' => $ this -> parseDirectives ( false ) , 'selectionSet' => $ this -> parseSelectionSet ( ) , 'loc' => $ this -> loc ( $ start ) , ] ) ; }
@return OperationDefinitionNode

@throws SyntaxError
@return OperationDefinitionNode