GraphQL support

Moesif supports GraphQL APIs throughout the platform. However there are a few differences compared to other APIs such as REST and RPC. The most obvious difference is that unlike REST APIs, GraphQL APIs usually have only a single route

Moesif will parse your GraphQL operations into its respective components so that you can filter and segment by particular resources fetched or variables in your query. In fact, the flexible and detailed queries brought by GraphQL makes Moesif’s API Analytics even more powerful.

The parsed GraphQL metadata is available in request.graphql.XXX

In the below example, we are segmenting by, 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 GrapQL 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") {
     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.XXX

GraphQL Filtering

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

Bucketing and alerting on errors

Moesif will support matching on specific operation names and operation types to bucket a particular type of API call. This ensures you don’t just have a single bucket under the route POST /graphql.