Limits and errors
The query size limits of the FrontStage API, the error shape, and the error codes to handle
The FrontStage API checks each query before it runs it, and stops a request that reads too much data. Handle the errors on this page in every client.
Query limits
Basker checks these limits when it parses the query. A query over a limit does not run.
| Limit | Value | Error message starts with |
|---|---|---|
| Depth: the number of nested selections | 20 | Syntax Error: Query depth limit of 20 exceeded |
| Aliases in one query | 20 | Syntax Error: Aliases limit of 20 exceeded |
| Directives in one query | 20 | Syntax Error: Directives limit of 20 exceeded |
| Tokens in the query text | 6,000 | Syntax Error: Token limit of 6000 exceeded |
| Cost: each selected object costs 2 and each scalar field costs 0 | 20,000 | Syntax Error: Query Cost limit of 20000 exceeded |
The token limit error has the code GRAPHQL_PARSE_FAILED. The other limit errors have no extensions.code, so read the message. To get under a limit, select fewer fields, nest fewer levels, or split the query into two queries.
The API also limits page sizes. A limit above the maximum uses the maximum. See Pagination and filtering.
Request work limit
While a query runs, Basker counts the data it reads. A request stops when it goes over one of these limits:
| Limit | Value |
|---|---|
| Time | 45 seconds |
| Reads | 500 |
| Records in one read | 10,000 |
| Records in one request | 50,000 |
A stopped request returns HTTP status 503 with the plain-text body Temporarily unavailable and Cache-Control: no-store. The body is not JSON. Do not retry the same query. Make it smaller: lower limit, select fewer nested lists, or split it.
Error shape
GraphQL errors use the standard shape:
{
"errors": [
{
"message": "Syntax Error: Expected Name, found <EOF>.",
"locations": [{ "line": 1, "column": 16 }],
"extensions": { "code": "GRAPHQL_PARSE_FAILED" }
}
]
}A response can have both data and errors. A field that fails returns null in data, and the error has a path to that field. On production sites, the message of an unexpected server error is Unexpected error..
Error codes
| Code | HTTP status | Cause |
|---|---|---|
GRAPHQL_PARSE_FAILED | 200 | The query text is not valid GraphQL. |
GRAPHQL_VALIDATION_FAILED | 200 | The query asks for a field or argument that the schema does not have, or an argument has the wrong type. The message hides field suggestions. |
OPERATION_RESOLUTION_FAILURE | 200 | The query has more than one operation and no operationName. |
BAD_REQUEST | 405 | The query is a mutation. The API is read-only. |
PERSISTED_QUERY_NOT_FOUND | 200 | The site does not know the hash. Send the query again. See Persisted queries. |
PERSISTED_QUERY_HASH_MISMATCH | 400 | The hash does not match the query text. |
PERSISTED_QUERY_TOO_LARGE | 400 | The query is too long to register. |
BAD_REQUEST | 400 | The variables parameter is not a JSON object. |
| None | 400 | A required variable is missing, or a variable has the wrong type. |
Other failures do not return GraphQL JSON:
| HTTP status | Body | Cause |
|---|---|---|
400 | Invalid locale parameter | The site does not offer the locale value. |
503 | Temporarily unavailable | The request went over the work limit. |
Basker never caches a response that has an error. See Caching.
Handle errors in code
Check the status, then the errors array:
const response = await fetch(url);
if (!response.headers.get("content-type")?.includes("application/json")) {
throw new Error(`FrontStage API returned ${response.status}: ${await response.text()}`);
}
const { data, errors } = await response.json();
if (errors?.length) {
throw new Error(errors.map((error: { message: string }) => error.message).join("\n"));
}With the client, query throws a FrontstageError with errors, status, and code. request returns the errors without throwing.