Download the PHP package endeavour-agency/laravel-query-insights without Composer
On this page you can find all versions of the php package endeavour-agency/laravel-query-insights. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download endeavour-agency/laravel-query-insights
More information about endeavour-agency/laravel-query-insights
Files in endeavour-agency/laravel-query-insights
Package laravel-query-insights
Short Description This packages aims to provide insights into performed queries. Multiple handlers exist to control what should be done with the query data.
License MIT
Homepage https://github.com/endeavour-agency/laravel-query-insights
Informations about the package laravel-query-insights
Laravel Query Insights
This package aims to provide query insights. By default, it comes with two handlers:
LogHandler
: Writes the executed queries to a log fileLighthouseResponseHandler
: Adds the executed queries to the extensions section of a Lighthouse GraphQL response.
Getting started
To get started, simply install the package.
Then, in a service provider, register the desired handlers with the QueryCollectorInterface
.
Configuration
The package comes with a configuration file which can be published through
Through the configuration file, the insights can be enabled or disabled. By default, insights will only
be enabled if config('app.debug')
evaluates to true
.
Alternatively, insights can be enabled or disabled through the QUERY_INSIGHTS_ENABLED
env variable.
Handlers
The package bundles a few handlers to get you started quickly.
Log handler
The log handler will log all executed queries to a log file. It accepts an instance of the Psr\Log\LoggerInterface
.
By default, it will log the queries to the default log channel (config('logging.default')
).
Example log handler output:
Lighthouse Response Handler
The Lighthouse response handler will add executed queries to the extensions section of the GraphQL responses bodies, when using Lighthouse.
Example Lighthouse response handler output:
Custom handlers
To create your own handler, simply create a class that implements the EndeavourAgency\LaravelQueryInsights\Contracts\HandlerInterface
interface. Then, register it like you would with the default handlers (see Getting started).