Guides

Apollo Tracing

Apollo Tracing is a performance tracing specification for GraphQL servers.
It's not part of the actual GraphQLspecification itself, but there is a
common aggrement in the GraphQL community that this should be supported by
all GraphQL servers.

Enabeling Apollo Tracing

Due to built-in Apollo Tracing support it's actually very simple to enable
this feature. There is an option named TracingPreference which takes one of
three states. In the following table we find all of these states explained.

Key

Description

Never

Apollo Tracing is disabled; this is the default value.

OnDemand

Apollo Tracing is enabled partially which means that it traces only by passing a special header to a specific query request.

Always

Apollo Tracing is enabled completely which means all query requests will be traced automatically.

When creating your GraphQL schema, we just need to add an additional option
object to enable Apollo Tracing. By default, as explained in the above table
Apollo Tracing is disabled. Let's take a look at the first example which
describes how Apollo Tracing is enabled permanently.

Second, we have to pass an HTTP header GraphQL-Tracing=1 on the client-side
with every query request we're interested in.

When not using the Hot Chocolate ASP.Net Core or Framework stack we have to
implement the mapping from the HTTP header to the query request property by
our self which isn't very difficult actually. See how it's solved in the
Hot ChocolateASP.Net Core and Framework stack.