Basker Docs

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.

LimitValueError message starts with
Depth: the number of nested selections20Syntax Error: Query depth limit of 20 exceeded
Aliases in one query20Syntax Error: Aliases limit of 20 exceeded
Directives in one query20Syntax Error: Directives limit of 20 exceeded
Tokens in the query text6,000Syntax Error: Token limit of 6000 exceeded
Cost: each selected object costs 2 and each scalar field costs 020,000Syntax 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:

LimitValue
Time45 seconds
Reads500
Records in one read10,000
Records in one request50,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

CodeHTTP statusCause
GRAPHQL_PARSE_FAILED200The query text is not valid GraphQL.
GRAPHQL_VALIDATION_FAILED200The 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_FAILURE200The query has more than one operation and no operationName.
BAD_REQUEST405The query is a mutation. The API is read-only.
PERSISTED_QUERY_NOT_FOUND200The site does not know the hash. Send the query again. See Persisted queries.
PERSISTED_QUERY_HASH_MISMATCH400The hash does not match the query text.
PERSISTED_QUERY_TOO_LARGE400The query is too long to register.
BAD_REQUEST400The variables parameter is not a JSON object.
None400A required variable is missing, or a variable has the wrong type.

Other failures do not return GraphQL JSON:

HTTP statusBodyCause
400Invalid locale parameterThe site does not offer the locale value.
503Temporarily unavailableThe 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.

On this page