- Date
Tracing for WPGraphQL
In 2015, Huey Petersen wrote an article about instrumenting a GraphQL schema to track resolver times and provide insight into how the GraphQL server is performing. Since then Apollo Optics has taken the instrumentation to a new level, providing a SaaS solution for storing data about your GraphQL requests. The Apollo team has also been working on a proposal to standardize the instrumentation, and they’re calling it Apollo Tracing.
The proposed spec is still young, but the goal is to come up with a standard for how GraphQL schemas should record performance metrics for requests and their resolvers so that tools like Apollo and perhaps even GraphiQL or others can make use of these standard extensions.
While the spec is still young, having these metrics is pretty important for us, so we’ve introduced WPGraphQL Insights. It’s a plugin that adds tracing to your WPGraphQL server. The plugin is pretty early in development, so I wouldn’t suggest running it in production quite yet, but feel free to test it out on your local/dev environments and provide any feedback on the Github repo so we can make it better!
The near-future plans for the WPGraphQL Insights plugin are:
- add the ability for the server to enable/disable tracing
- add a settings page
- define via a constant, ex: define( ‘GRAPHQL_TRACING’, true );
- allow the client to request tracing in the response (see this discussion)
- provide storage options for the trace data
- We’re working with the Apollo Optics team to figure out how we can get the trace data from a WPGraphQL server into Optics
- We’re experimenting with storing trace data locally in WordPress to some degree
- We’re experimenting with sending the data elsewhere, like logstash/elasticsearch.
Here’s a look at tracing in action on WPGraphQL. Enjoy!