Kest

Search

Search the documentation

GraphQL

Plugins

Hook into query execution with a graphql-java Instrumentation.

A plugin is a graphql-java Instrumentation: it is told when a query starts, when each field is fetched and when the query ends. Use it for tracing, metrics, persisted queries or caching.

useGraphQL {
    schema = SDL
    plugin(TracingInstrumentation())           // from graphql-java
    plugin(object : SimplePerformantInstrumentation() {
        override fun beginExecution(p: InstrumentationExecutionParameters, s: InstrumentationState?) =
            metrics.counter("graphql.queries").also { it.increment() }.let { super.beginExecution(p, s) }
    })
}

The built-in depth and complexity limits (Complexity) are themselves instrumentations and run alongside yours.

Read more