public static function getOperation(DocumentNode $document, $operationName = null)
    {
        if ($document->definitions) {
            foreach ($document->definitions as $def) {
                if (! ($def instanceof OperationDefinitionNode)) {
                    continue;
                }

                if (! $operationName || (isset($def->name->value) && $def->name->value === $operationName)) {
                    return $def->operation;
                }
            }
        }

        return false;
    }
public static function getOperation(DocumentNode $document, $operationName = null)
    {
        if ($document->definitions) {
            foreach ($document->definitions as $def) {
                if (! ($def instanceof OperationDefinitionNode)) {
                    continue;
                }

                if (! $operationName || (isset($def->name->value) && $def->name->value === $operationName)) {
                    return $def->operation;
                }
            }
        }

        return false;
    }
public static function getOperation ( DocumentNode $ document , $ operationName = null ) { if ( $ document -> definitions ) { foreach ( $ document -> definitions as $ def ) { if ( ! ( $ def instanceof OperationDefinitionNode ) ) { continue ; } if ( ! $ operationName || ( isset ( $ def -> name -> value ) && $ def -> name -> value === $ operationName ) ) { return $ def -> operation ; } } } return false ; }
Returns operation type ("query", "mutation" or "subscription") given a document and operation name

@param string $operationName

@return bool

@api
Returns operation type ( query mutation or subscription ) given a document and operation name