> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GraphQL

[GraphQL](https://graphql-ruby.org/) 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.

<CodeGroup>
  ```ruby Ruby theme={null}
  # TODO: Change the schema class to your schema class
  class MySchema < GraphQL::Schema
    trace_with(GraphQL::Tracing::AppsignalTrace)
  end
  ```
</CodeGroup>

* Reference: [GraphQL AppSignal docs](https://graphql-ruby.org/queries/tracing.html#appsignal).

## 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](/guides/namespaces) and action name:

<CodeGroup>
  ```ruby Ruby theme={null}
  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
  ```
</CodeGroup>
