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

# Pagination, sorting, and filtering

> Learn how to paginate, sort, and filter results in the Underwriting GraphQL API.

Tesouro's GraphQL API supports pagination and filtering on collection queries.

## Pagination

Collection queries accept a `paging` input with two fields:

| Field  | Type   | Description                               |
| ------ | ------ | ----------------------------------------- |
| `skip` | `Int!` | The number of records to skip (offset).   |
| `take` | `Int!` | The number of records to return per page. |

Each collection query returns a `pageInfo` object alongside the result `items`:

| Field             | Type       | Description                                 |
| ----------------- | ---------- | ------------------------------------------- |
| `hasNextPage`     | `Boolean!` | Whether more records exist after this page. |
| `hasPreviousPage` | `Boolean!` | Whether records exist before this page.     |

### Example

```graphql lines theme={null}
query ListItems($input: ListItemsInput!) {
  listItems(input: $input) {
    items {
      id
      createdAt
      status
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
  }
}
```

```json title="Variables" lines theme={null}
{
  "input": {
    "paging": {
      "skip": 0,
      "take": 25
    }
  }
}
```

To retrieve the next page, increment `skip` by the `take` value:

```json lines theme={null}
{
  "input": {
    "paging": {
      "skip": 25,
      "take": 25
    }
  }
}
```

Continue paginating until `pageInfo.hasNextPage` is `false`.

## Filtering

Collection queries accept a `where` input containing typed filter fields. The available filter fields vary by query. Common filter input types include:

| Filter type            | Operators         | Description                                        |
| ---------------------- | ----------------- | -------------------------------------------------- |
| `GuidFilterInput`      | `eq`, `in`        | Filter by a single UUID or a list of UUIDs.        |
| `StringFilterInput`    | `eq`, `in`        | Filter by exact string match or a list of strings. |
| `DateRangeFilterInput` | `gte`, `lte`      | Filter by a date range (inclusive).                |
| `EnumFilterInput`      | `eq`, `in`, `nin` | Filter by enum value, inclusion, or exclusion.     |

Refer to the schema reference for each query to see its available filter fields and types.
