public static function promiseToExecute(
        PromiseAdapter $promiseAdapter,
        SchemaType $schema,
        $source,
        $rootValue = null,
        $context = null,
        $variableValues = null,
        ?string $operationName = null,
        ?callable $fieldResolver = null,
        ?array $validationRules = null
    ) : Promise {
        try {
            if ($source instanceof DocumentNode) {
                $documentNode = $source;
            } else {
                $documentNode = Parser::parse(new Source($source ?: '', 'GraphQL'));
            }

            // FIXME
            if (empty($validationRules)) {
                /** @var QueryComplexity $queryComplexity */
                $queryComplexity = DocumentValidator::getRule(QueryComplexity::class);
                $queryComplexity->setRawVariableValues($variableValues);
            } else {
                foreach ($validationRules as $rule) {
                    if (! ($rule instanceof QueryComplexity)) {
                        continue;
                    }

                    $rule->setRawVariableValues($variableValues);
                }
            }

            $validationErrors = DocumentValidator::validate($schema, $documentNode, $validationRules);

            if (! empty($validationErrors)) {
                return $promiseAdapter->createFulfilled(
                    new ExecutionResult(null, $validationErrors)
                );
            }

            return Executor::promiseToExecute(
                $promiseAdapter,
                $schema,
                $documentNode,
                $rootValue,
                $context,
                $variableValues,
                $operationName,
                $fieldResolver
            );
        } catch (Error $e) {
            return $promiseAdapter->createFulfilled(
                new ExecutionResult(null, [$e])
            );
        }
    }
public static function promiseToExecute(
        PromiseAdapter $promiseAdapter,
        SchemaType $schema,
        $source,
        $rootValue = null,
        $context = null,
        $variableValues = null,
        ?string $operationName = null,
        ?callable $fieldResolver = null,
        ?array $validationRules = null
    ) : Promise {
        try {
            if ($source instanceof DocumentNode) {
                $documentNode = $source;
            } else {
                $documentNode = Parser::parse(new Source($source ?: '', 'GraphQL'));
            }

            
            if (empty($validationRules)) {
                
                $queryComplexity = DocumentValidator::getRule(QueryComplexity::class);
                $queryComplexity->setRawVariableValues($variableValues);
            } else {
                foreach ($validationRules as $rule) {
                    if (! ($rule instanceof QueryComplexity)) {
                        continue;
                    }

                    $rule->setRawVariableValues($variableValues);
                }
            }

            $validationErrors = DocumentValidator::validate($schema, $documentNode, $validationRules);

            if (! empty($validationErrors)) {
                return $promiseAdapter->createFulfilled(
                    new ExecutionResult(null, $validationErrors)
                );
            }

            return Executor::promiseToExecute(
                $promiseAdapter,
                $schema,
                $documentNode,
                $rootValue,
                $context,
                $variableValues,
                $operationName,
                $fieldResolver
            );
        } catch (Error $e) {
            return $promiseAdapter->createFulfilled(
                new ExecutionResult(null, [$e])
            );
        }
    }
public static function promiseToExecute ( PromiseAdapter $ promiseAdapter , SchemaType $ schema , $ source , $ rootValue = null , $ context = null , $ variableValues = null , ? string $ operationName = null , ? callable $ fieldResolver = null , ? array $ validationRules = null ) : Promise { try { if ( $ source instanceof DocumentNode ) { $ documentNode = $ source ; } else { $ documentNode = Parser :: parse ( new Source ( $ source ? : '' , 'GraphQL' ) ) ; } // FIXME if ( empty ( $ validationRules ) ) { /** @var QueryComplexity $queryComplexity */ $ queryComplexity = DocumentValidator :: getRule ( QueryComplexity :: class ) ; $ queryComplexity -> setRawVariableValues ( $ variableValues ) ; } else { foreach ( $ validationRules as $ rule ) { if ( ! ( $ rule instanceof QueryComplexity ) ) { continue ; } $ rule -> setRawVariableValues ( $ variableValues ) ; } } $ validationErrors = DocumentValidator :: validate ( $ schema , $ documentNode , $ validationRules ) ; if ( ! empty ( $ validationErrors ) ) { return $ promiseAdapter -> createFulfilled ( new ExecutionResult ( null , $ validationErrors ) ) ; } return Executor :: promiseToExecute ( $ promiseAdapter , $ schema , $ documentNode , $ rootValue , $ context , $ variableValues , $ operationName , $ fieldResolver ) ; } catch ( Error $ e ) { return $ promiseAdapter -> createFulfilled ( new ExecutionResult ( null , [ $ e ] ) ) ; } }
Same as executeQuery(), but requires PromiseAdapter and always returns a Promise.
Useful for Async PHP platforms.

@param string|DocumentNode   $source
@param mixed                 $rootValue
@param mixed                 $context
@param mixed[]|null          $variableValues
@param ValidationRule[]|null $validationRules

@api
Same as executeQuery () but requires PromiseAdapter and always returns a Promise . Useful for Async PHP platforms .