operation static method
OperationDefinitionNode
operation(})
Creates an OperationDefinitionNode with simplified syntax.
This helper reduces the verbosity of operation definition creation.
Example:
operation(
OperationType.query,
'simple_query',
selections: [field('pokemon', selections: [field('number')])],
)
Implementation
static OperationDefinitionNode operation(
OperationType type,
String name, {
List<VariableDefinitionNode>? variables,
List<SelectionNode>? selections,
}) {
return OperationDefinitionNode(
type: type,
name: nameNode(name),
variableDefinitions: variables ?? [],
selectionSet: SelectionSetNode(selections: selections ?? []),
);
}