Automattic\WooCommerce\Api\Infrastructure
GraphQLControllerBase::document_has_mutation
Check whether the parsed document contains a mutation operation.
When an operation name is given, only that operation is checked; otherwise any mutation definition in the document triggers a match.
Method of the class: GraphQLControllerBase{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->document_has_mutation( $document, ?string $operation_name ): bool;
- $document(DocumentNode) (required)
- The parsed GraphQL document.
- ?string $operation_name(required)
- .
GraphQLControllerBase::document_has_mutation() GraphQLControllerBase::document has mutation code WC 10.9.4
private function document_has_mutation( DocumentNode $document, ?string $operation_name ): bool {
foreach ( $document->definitions as $definition ) {
if ( ! $definition instanceof OperationDefinitionNode ) {
continue;
}
if ( null !== $operation_name && ( $definition->name->value ?? null ) !== $operation_name ) {
continue;
}
if ( 'mutation' === $definition->operation ) {
return true;
}
}
return false;
}