GraphQL support

Moesif natively supports GraphQL APIs throughout the entire platform. For an overview, go to Moesif GraphQL Analytics and Monitoring.

Moesif will parse your GraphQL operations into its respective components so that you can filter and aggregate on any GraphQL query fields including GraphQL selectors and variables. This also enables you to create complex alerts in Moesif based on specific resources or responses even if the status code is always 200 OK.

The parsed GraphQL query fields are available under request.graphql

In the below example, we are segmenting by request.graphql.definitions.name, and then selecting to plot both the max and avg latency over time.

viewing a breakdown of latency by operation name

Comparing GraphQL Analytics vs REST Analytics

Moesif can provide insight into how your GraphQL APIs are accessed compared to your REST APIs. This enables you to track how the usage differs if you’re migrating from REST to GraphQL.

For example, the first screenshot shows a breakdown of mutate operations by definition name. The REST equivalent shows a breakdown of non GET API transactions broken down by REST route.

viewing a breakdown of GraphQL operations by definition name

viewing a breakdown of REST calls by route

GraphQL over HTTP

There are four different ways GraphQL can be transported over HTTP which Moesif supports.

  1. If the application/graphql Content-Type header is present, the HTTP request body contents is treated as the GraphQL query string itself.
    {
      human(id: "1000") {
     name
     height(unit: FOOT)
      }
    }
    
  2. The GraphQL query string is specified in the ?query= query string when receiving a HTTP GET request.

  3. A standard GraphQL POST request which uses the application/json content type includes a JSON-encoded request body of the following form: json { 'query': '...', 'operationName': '...', 'variables': { 'myVariable': 'someValue', ... } }

  4. Alternatively, the GraphQL query string is specified in the ?query= query string when receiving a HTTP POST request.

Filters and segmentation

If Moesif detects a GraphQL request, you will see the parsed AST underneath request.graphql

GraphQL Filtering

You can select any attribute in your GraphQL operation such as a specific query field name or argument value.

Updated: