Automattic\WooCommerce\Vendor\GraphQL\Language
Parser::parseFragmentDefinition
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() 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),
]);
}