GraphQL\Language\Parser::parseFragment PHP Method

parseFragment() public method

public parseFragment ( ) : FragmentSpreadNode | InlineFragmentNode
return GraphQL\Language\AST\FragmentSpreadNode | GraphQL\Language\AST\InlineFragmentNode
    function parseFragment()
    {
        $start = $this->lexer->token;
        $this->expect(Token::SPREAD);
        if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') {
            return new FragmentSpreadNode(['name' => $this->parseFragmentName(), 'directives' => $this->parseDirectives(), 'loc' => $this->loc($start)]);
        }
        $typeCondition = null;
        if ($this->lexer->token->value === 'on') {
            $this->lexer->advance();
            $typeCondition = $this->parseNamedType();
        }
        return new InlineFragmentNode(['typeCondition' => $typeCondition, 'directives' => $this->parseDirectives(), 'selectionSet' => $this->parseSelectionSet(), 'loc' => $this->loc($start)]);
    }