src/GraphQL.php
public function executeQuery(
        $query,
        GraphQLContext $context,
        ?array $variables = [],
        $rootValue = null,
        ?string $operationName = null
    ): ExecutionResult {
        // Building the executable schema might take a while to do,
        // so we do it before we fire the StartExecution event.
        // This allows tracking the time for batched queries independently.
        $this->prepSchema();

        $this->eventDispatcher->dispatch(
            new StartExecution
        );

        $result = GraphQLBase::executeQuery(
            $this->executableSchema,
            $query,
            $rootValue,
            $context,
            $variables,
            $operationName,
            null,
            $this->getValidationRules() + DocumentValidator::defaultRules()
        );

        /** @var \Nuwave\Lighthouse\Execution\ExtensionsResponse[] $extensionsResponses */
        $extensionsResponses = (array) $this->eventDispatcher->dispatch(
            new BuildExtensionsResponse
        );

        foreach ($extensionsResponses as $extensionsResponse) {
            if ($extensionsResponse) {
                $result->extensions[$extensionsResponse->key()] = $extensionsResponse->content();
            }
        }

        $result->setErrorsHandler(
            function (array $errors, callable $formatter): array {
                // User defined error handlers, implementing \Nuwave\Lighthouse\Execution\ErrorHandler
                // This allows the user to register multiple handlers and pipe the errors through.
                $handlers = config('lighthouse.error_handlers', []);

                return array_map(
                    function (Error $error) use ($handlers, $formatter) {
                        return $this->pipeline
                            ->send($error)
                            ->through($handlers)
                            ->then(function (Error $error) use ($formatter) {
                                return $formatter($error);
                            });
                    },
                    $errors
                );
            }
        );

        // Allow listeners to manipulate the result after each resolved query
        $this->eventDispatcher->dispatch(
            new ManipulateResult($result)
        );

        return $result;
    }
public function executeQuery(
        $query,
        GraphQLContext $context,
        ?array $variables = [],
        $rootValue = null,
        ?string $operationName = null
    ): ExecutionResult {
        // Building the executable schema might take a while to do,
        // so we do it before we fire the StartExecution event.
        // This allows tracking the time for batched queries independently.
        $this->prepSchema();

        $this->eventDispatcher->dispatch(
            new StartExecution
        );

        $result = GraphQLBase::executeQuery(
            $this->executableSchema,
            $query,
            $rootValue,
            $context,
            $variables,
            $operationName,
            null,
            $this->getValidationRules() + DocumentValidator::defaultRules()
        );

        /** @var \Nuwave\Lighthouse\Execution\ExtensionsResponse[] $extensionsResponses */
        $extensionsResponses = (array) $this->eventDispatcher->dispatch(
            new BuildExtensionsResponse
        );

        foreach ($extensionsResponses as $extensionsResponse) {
            if ($extensionsResponse) {
                $result->extensions[$extensionsResponse->key()] = $extensionsResponse->content();
            }
        }

        $result->setErrorsHandler(
            function (array $errors, callable $formatter): array {
                // User defined error handlers, implementing \Nuwave\Lighthouse\Execution\ErrorHandler
                // This allows the user to register multiple handlers and pipe the errors through.
                $handlers = config('lighthouse.error_handlers', []);

                return array_map(
                    function (Error $error) use ($handlers, $formatter) {
                        return $this->pipeline
                            ->send($error)
                            ->through($handlers)
                            ->then(function (Error $error) use ($formatter) {
                                return $formatter($error);
                            });
                    },
                    $errors
                );
            }
        );

        // Allow listeners to manipulate the result after each resolved query
        $this->eventDispatcher->dispatch(
            new ManipulateResult($result)
        );

        return $result;
    }
public function executeQuery ( $ query , GraphQLContext $ context , ? array $ variables = [ ] , $ rootValue = null , ? string $ operationName = null ) : ExecutionResult { // Building the executable schema might take a while to do, // so we do it before we fire the StartExecution event. // This allows tracking the time for batched queries independently. $ this -> prepSchema ( ) ; $ this -> eventDispatcher -> dispatch ( new StartExecution ) ; $ result = GraphQLBase :: executeQuery ( $ this -> executableSchema , $ query , $ rootValue , $ context , $ variables , $ operationName , null , $ this -> getValidationRules ( ) + DocumentValidator :: defaultRules ( ) ) ; /** @var \Nuwave\Lighthouse\Execution\ExtensionsResponse[] $extensionsResponses */ $ extensionsResponses = ( array ) $ this -> eventDispatcher -> dispatch ( new BuildExtensionsResponse ) ; foreach ( $ extensionsResponses as $ extensionsResponse ) { if ( $ extensionsResponse ) { $ result -> extensions [ $ extensionsResponse -> key ( ) ] = $ extensionsResponse -> content ( ) ; } } $ result -> setErrorsHandler ( function ( array $ errors , callable $ formatter ) : array { // User defined error handlers, implementing \Nuwave\Lighthouse\Execution\ErrorHandler // This allows the user to register multiple handlers and pipe the errors through. $ handlers = config ( 'lighthouse.error_handlers' , [ ] ) ; return array_map ( function ( Error $ error ) use ( $ handlers , $ formatter ) { return $ this -> pipeline -> send ( $ error ) -> through ( $ handlers ) -> then ( function ( Error $ error ) use ( $ formatter ) { return $ formatter ( $ error ) ; } ) ; } , $ errors ) ; } ) ; // Allow listeners to manipulate the result after each resolved query $ this -> eventDispatcher -> dispatch ( new ManipulateResult ( $ result ) ) ; return $ result ; }
Execute a GraphQL query on the Lighthouse schema and return the raw ExecutionResult.

To render the ExecutionResult, you will probably want to call `->toArray($debug)` on it,
with $debug being a combination of flags in \GraphQL\Error\Debug

@param  string|\GraphQL\Language\AST\DocumentNode  $query
@param  \Nuwave\Lighthouse\Support\Contracts\GraphQLContext  $context
@param  mixed[]  $variables
@param  mixed|null  $rootValue
@param  string|null  $operationName
@return \GraphQL\Executor\ExecutionResult
Execute a GraphQL query on the Lighthouse schema and return the raw ExecutionResult .