Skip to content

How-to guide

GraphQL API monitoring

GraphQL puts everything behind one endpoint and usually answers 200 even when things fail. Monitoring has to look inside the response and at each operation.

3 min read13 sectionsUpdated

On this page

Key points

  • A 200 response can contain errors: check the errors array.
  • Group metrics by operation name, not by URL.
  • Trace resolvers to find slow fields and N+1 data loading.
  • Limit query depth and cost to protect the server.

Errors live in the body

A GraphQL server typically returns HTTP 200 with partial data and an errors array. A status-only uptime check will report success while users see failures.

json
{
  "data": { "order": null },
  "errors": [{ "message": "Payment service unavailable", "path": ["order", "payment"], "extensions": { "code": "UPSTREAM_TIMEOUT" } }]
}

An uptime check that understands GraphQL

plaintext
POST https://api.example.com/graphql
header  content-type: application/json
body    {"operationName":"Health","query":"query Health { viewer { id } status { db cache } }"}
expect  status = 200
expect  body does not contain "\"errors\""
expect  body contains "\"db\":\"ok\""
expect  time < 1000 ms

Measure per operation

Every request goes to POST /graphql, so URL-based metrics show one meaningless row. Require clients to send an operationName and use it as the span name or a metric label (it is low-cardinality). Then you get request rate, error rate and p95 per operation: GetProduct, CreateOrder, SearchCatalog.

Trace resolvers

OpenTelemetry instrumentation for GraphQL servers (for example @opentelemetry/instrumentation-graphql for Node.js) creates spans for parsing, validation and resolvers. Watch for:

  • Resolver N+1: a list field whose child resolver queries the database once per item. Use a DataLoader to batch.
  • Slow fields: one expensive field requested by many queries.
  • Deep queries: nested selections multiplying work.

Protect the server

Set a maximum query depth and complexity, time out long-running operations, and consider persisted queries so only known operations run. Log rejected queries; a spike can signal abuse.

In VitalRix

API monitoring supports POST bodies, headers and assertions on the response body, including multi-step flows that pass values between requests. APM shows latency and errors per span name from OpenTelemetry traces, so operation-named spans become rows you can sort and alert on.

Fixing resolver N+1 with DataLoader

resolvers.tstypescript
import DataLoader from 'dataloader';

// one loader per request: batches all customer lookups made while resolving a query
const customerLoader = new DataLoader(async (ids: readonly string[]) => {
  const rows = await db.customers.findMany({ where: { id: { in: [...ids] } } });
  const byId = new Map(rows.map((r) => [r.id, r]));
  return ids.map((id) => byId.get(id) ?? null);
});

const resolvers = {
  Order: { customer: (order) => customerLoader.load(order.customerId) },
};

What to put on a GraphQL dashboard

Requests and errors per operation name, p95 per operation, the slowest resolvers by total time, rejected queries (depth or cost limits) and the share of responses that contain an errors array. The last one is the number most HTTP-level dashboards miss entirely.

Frequently asked questions

Should GraphQL errors return 500?

Most servers return 200 for field-level errors and reserve non-200 codes for transport problems. Monitor the errors array either way.

How do I find slow GraphQL queries?

Trace resolvers, group by operation name and sort by p95. The slow trace shows which resolver and which database call dominate.

Check it now, free

  • How to monitor Supabase: How to monitor a Supabase backend: Postgres health and slow queries, auth and REST API availability, edge function errors, connection limits and alerts.
  • WordPress monitoring: uptime, speed and errors: Monitor a WordPress site: uptime with content checks, login and admin, Core Web Vitals, PHP errors, plugin updates, SSL expiry and backups.
  • Monitoring APIs for mobile apps: Monitor the backend of a mobile app: API latency and errors per endpoint, failures by app version, push and sync jobs and regional performance.
  • What is API testing?: API testing explained: functional, contract, load and security tests, what to assert on, tools, and running API checks continuously in production as monitoring.
  • Best synthetic monitoring tools: Choose a synthetic monitoring tool in 2026: API and browser checks, scripting, locations, private networks and CI use, with well-known options compared.
  • How to monitor a Next.js app: How to monitor a Next.js app in production: uptime checks, Core Web Vitals, server and edge errors, OpenTelemetry traces for SSR and API routes, and alerts.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.