Healthchecks
GraphQL Health Checks
Monitor GraphQL endpoints with custom queries, variables, headers, and response validation.
Overview
GraphQL health checks let you monitor your GraphQL API endpoints by executing actual GraphQL queries and validating the responses. Unlike simple HTTP checks that only verify connectivity, GraphQL checks ensure your schema is loaded, resolvers are working, and the endpoint returns valid data.
By default, Uptimy sends a lightweight introspection query ({ __typename }) that works with any GraphQL server. You can customize this to run any query that represents a meaningful health indicator for your application.
Configuration
| Parameter | Description | Default |
|---|---|---|
| Endpoint URL | The full URL of your GraphQL endpoint | Required |
| GraphQL Query | The GraphQL query to execute | { __typename } |
| Request headers | Additional HTTP headers (e.g., authentication tokens) | Empty |
| Checks | What the response must look like: a JSON field, a keyword, the status code, a header or the response time | None |
Checks are under the endpoint URL in the app. The query and headers are under Advanced settings.
Checks
GraphQL checks take the same checks as HTTP checks, and every check must pass for the monitor to be up. JSON fields are read from the whole response, so their paths start at data: for the query { health { status } }, add JSON field data.health.status equals ok.
Two rules always apply, with or without checks:
- The status code must be 2xx, unless you add a status code check.
- The response must have no GraphQL errors. An empty
errorslist is fine.
A failed result lists every check that failed, with what was expected and what came back. GraphQL errors come first, with their messages.
Custom Queries
You can use any valid GraphQL query to verify the health of your API. Here are some common patterns:
Basic Introspection (Default)
{
__typename
}This is the simplest possible query. It verifies that the GraphQL server is running, the schema is loaded, and the endpoint can process requests.
Application-Level Health Check
query HealthCheck {
health {
status
database
cache
version
}
}A custom health query can verify that downstream dependencies like databases and caches are also operational.
Query with Variables
The app has no field for variables. Set them as variables in the check's config through the API or uptimyctl:
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}{
"id": "health-check-user-id"
}Choose Lightweight Queries
Use the simplest query that gives you confidence your API is working. Heavy queries with deep nesting or large result sets add unnecessary load to your server and increase check duration. The default __typename query is ideal for basic availability monitoring.
Response Data
Each GraphQL health check execution captures the following data:
| Field | Description |
|---|---|
| HTTP Status Code | The HTTP status code returned by the endpoint (typically 200 for GraphQL) |
| GraphQL Success | Boolean indicating whether the query executed without errors |
| DNS Lookup | Time spent resolving the domain name |
| TCP Connection | Time to establish the TCP connection |
| TLS Handshake | Time for the SSL/TLS handshake (HTTPS only) |
| Time to First Byte | Time from request sent to first response byte received |
| Content Transfer | Time to download the complete response body |
GraphQL Error Handling
GraphQL APIs typically return HTTP 200 even when query errors occur. Uptimy reads the response body's GraphQL errors field: any error fails the check, even with a 200. This catches failures that an HTTP status check would miss.
Example Configuration
GraphQL is healthcheck type 3. This is its config as the API and uptimyctl take it. The interval and timeout aren't part of it: they are set on the check itself, as intervalSeconds and timeoutSeconds.
{
"uri": "https://api.example.com/graphql",
"query": "query GetUser($id: ID!) { user(id: $id) { id } }",
"variables": { "id": "health-check-user-id" },
"headers": {
"Authorization": "Bearer your-api-token"
},
"assertions": [
{ "source": "json", "path": "data.user.id", "op": "eq", "value": "health-check-user-id" },
{ "source": "response_time", "op": "lt", "value": 2000 }
]
}assertions are written as for HTTP checks. The older expectedResponse field is no longer accepted: write each field as a JSON field check instead.
For choosing the query and what to check, see GraphQL Monitoring: Why 200 OK Doesn't Mean the Query Worked.
Authentication
If your GraphQL endpoint requires authentication, add the necessary headers under Request headers. Ensure your monitoring credentials have minimal read-only permissions to follow the principle of least privilege.