> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kralis.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors, Pagination, and Reliability

> Handle GraphQL and REST failures, cursor connections, retries, and changing school data.

## GraphQL errors

A GraphQL HTTP response can contain `errors` even when the transport request completed. Check both `data` and `errors`; do not treat HTTP `200` alone as application success.

| Error class                   | Client response                                                       |
| ----------------------------- | --------------------------------------------------------------------- |
| Authentication                | Refresh once when appropriate, otherwise sign out                     |
| Authorization                 | Stop the action and update the UI to reflect unavailable access       |
| Validation                    | Preserve inputs and show the server message near the action or field  |
| Not found                     | Remove stale selection and return to an available list                |
| Rate limit                    | Disable repeated submission and retry only after the indicated window |
| Provider or temporary failure | Keep persisted Kralis state authoritative and offer a safe retry      |

## REST errors

Use HTTP status and the documented response body. Handle invalid credentials, expired tokens, forbidden access, validation errors, rate limits, and server failures separately.

## Cursor pagination

Kralis GraphQL lists commonly use Relay-style connections.

```graphql theme={null}
query ListBroadcasts($first: Int!, $after: String) {
  broadCasts(first: $first, after: $after) {
    edges {
      node {
        pk
        title
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}
```

```mermaid theme={null}
flowchart LR
    A[Fetch first page] --> B[Render edges]
    B --> C{hasNextPage?}
    C -->|Yes| D[Fetch with endCursor]
    D --> E[Merge by stable node ID]
    E --> C
    C -->|No| F[Complete list]
```

Never silently assume a fixed first page contains the whole school. Search selectors, event lists, students, recordings, and other growing datasets must support pagination.

## Retry safety

Queries are generally safe to retry. Mutations may not be. Disable duplicate submission, retain operation state, and refetch after an uncertain response before repeating a create, payment, result, promotion, or recording action.

## Changing data

Another Kralis Web user or custom client can change the same school data. Refetch after important mutations, use realtime or polling only where the product contract supports it, and avoid assuming cached permissions remain valid forever.
