All PostsInside Skylight Learn about Skylight

Announcing Skylight for GraphQL! 🀝

Skylight 4.2.0 now includes GraphQL instrumentation! To use it, upgrade the Skylight gem and add 'graphql' to your probes list. We support graphql-ruby versions >= 1.7.

A screenshot of the GraphQL probe in the Skylight UI.

How does it work?

GraphQL is a new API implementation strategy that works somewhat differently from traditional Rails APIs. Instead of writing a controller action to represent each endpoint, every query sent to a GraphQL API is typically handled by a single controller and action. When it comes to profiling performance for this endpoint on Skylight, however, things get tricky. Though we may want to inspect the particular performance characteristics of one query, the waters are muddied if all of your queries are aggregated under this single endpoint. For customers using GraphQL, this is (unfortunately) exactly what they would have seen, since Skylight was originally written to serve the one-endpoint-per-action model.

Luckily, the GraphQL spec includes an optional Operation Name field that helps identify and group together particular queries. Skylight uses the operation name to determine the endpoint name and group your queries together. This means that even though all of your GraphQL requests are sent to a single controller, your queries will be aggregated by name in the Skylight dashboard! πŸŽ‰ Skylight's GraphQL instrumentation works best when naming queries because it helps us keep like data with like.

What about multiplexed queries?

Skylight names your endpoint based on all of the queries sent in a single request. For example, if you send two named queries together, your endpoint name will be a combination of those two query names.

Named and multiplexed queries in the Skylight UI.

Handling anonymous queries

Skylight groups all single anonymous queries under one endpoint. While your anonymous queries will still be tracked, you may notice that any spans under GraphQL::Schema#execute are ignored.

Anonymous queries with the GraphQL probe enabled in Skylight.

We intentionally ignore child nodes of anonymous queries because their divergent traces can’t be aggregated in a way that would provide actionable insights. We highly recommend using named queries with the GraphQL probe in order to get the most out of Skylight instrumentation!

You can learn more about this feature in our documentation. We hope you'll give it a try and tell us what you think!

If Skylight sounds useful to you, or if you have some endpoints like these ones that you'd like to investigate further, sign up today and get a free 30-day trial. Or, refer a friend and you'll both get $50 in credit!

Skylight

Start your free month or refer a friend and get a $50 credit.