Skip to main content
GraphQL is the Ruby gem for GraphQL servers. AppSignal supports the GraphQL gem through the built-in instrumentation module in the GraphQL gem.

Instrumentation

To instrument your GraphQL app using AppSignal, load the AppSignal middleware in your schema.
# TODO: Change the schema class to your schema class
class MySchema < GraphQL::Schema
  trace_with(GraphQL::Tracing::AppsignalTrace)
end

Customize namespace and action

You can AppSignal instrumentation helper methods to customize your instrumentation further. In the example below we group the requests by namespace and action name:
class GraphqlController < ApplicationController
  def create
    result = MySchema.execute(params[:query], :variables => params[:variables], :context => {})
    render :json => result
  ensure
    # Customize the namespace
    Appsignal::Transaction.current.set_namespace("graphql")
    # Customize the action name based on the operationName, if any
    Appsignal::Transaction.current.set_action(params[:operationName] || "Unknown")
  end