Kest

Search

Search the documentation

GraphQL

Extensions

Add your own data to the response's extensions.

A GraphQL response may carry an extensions object next to data and errors. Set responseExtensions to compute it for every result:

useGraphQL {
    schema = SDL
    responseExtensions = { result -> mapOf("requestId" to RequestContext.current()?.requestId, "errors" to result.errors.size) }
}
{ "data": { "greeting": "hello" }, "extensions": { "requestId": "9f1c", "errors": 0 } }

Errors already carry extensions.code and extensions.status (see Resolvers); your entries are merged with whatever the engine adds.

Read more