GraphQL Instrumentation allows you to inject code that can observe the execution of a query and also change the runtime behaviour. Let's take advantage of this to log the graphql request's query, variables, any exceptions thrown and execution time.
To do this we create a spring bean of type graphql.execution.instrumentation.Instrumentation.
To remove boilerplace no-op code, we override no-op SimpleInstrumentation implementation and just override the beginExecution method.
We then return a SimpleInstrumentationContext with an whenCompleted callable containing our duration logic and log message.
It is possible that multiple Instrumentation objects are in one graphql server.
In the next video, I demo the TracingInstrumentation that will capture the execution time of the fields and place the results into the graphql response.
See you in the next video!
Cheers!
Philip
GraphQL Instrumentation: https://www.graphql-java.com/document...
Spring Boot GraphQL Java: https://github.com/graphql-java-kicks...
Good article on graphql paypal instrumentation: / graphql-instrumenting-your-api-and-unlocki...
Image on thumbnail: https://wallhaven.cc/w/ymepyg
On this page of the site you can watch the video online Spring Boot GraphQL Tutorial #24 - Instrumentation (Request Logging) with a duration of hours minute second in good quality, which was uploaded by the user Philip Starritt 11 October 2020, share the link with friends and acquaintances, this video has already been watched 5,194 times on youtube and it was liked by 52 viewers. Enjoy your viewing!