Automattic\WooCommerce\Vendor\GraphQL\Language

Parser::parseFragmentDefinition │ private │ WC 1.0

Method of the class: Parser{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->parseFragmentDefinition(): FragmentDefinitionNode;

Parser::parseFragmentDefinition() code WC 11.1.2

private function parseFragmentDefinition(): FragmentDefinitionNode
{
    $start = $this->lexer->token;
    $this->expectKeyword('fragment');

    $name = $this->parseFragmentName();

    // Experimental support for defining variables within fragments changes
    // the grammar of FragmentDefinition:
    //   - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
    $variableDefinitions = isset($this->lexer->options['experimentalFragmentVariables'])
        ? $this->parseVariableDefinitions()
        : null;

    $this->expectKeyword('on');
    $typeCondition = $this->parseNamedType();

    return new FragmentDefinitionNode([
        'name' => $name,
        'variableDefinitions' => $variableDefinitions,
        'typeCondition' => $typeCondition,
        'directives' => $this->parseDirectives(false),
        'selectionSet' => $this->parseSelectionSet(),
        'loc' => $this->loc($start),
    ]);
}