# Paginate through results

> Fetch every item from a list field using first, after and pageInfo.

Source: https://docs.gastrogate.io/docs/guides/pagination

List fields such as [`restaurants`](https://docs.gastrogate.io/docs/api/queries/restaurants.md) return a `…Page` type with `edges` and `pageInfo`.

## Fetch the first page

```graphql
query {
  restaurants(first: 25) {
    edges { cursor node { id } }
    pageInfo { hasNextPage endCursor }
  }
}
```

## Fetch the next page

Pass `pageInfo.endCursor` as `after`:

```graphql
query Next($after: String) {
  restaurants(first: 25, after: $after) {
    edges { node { id } }
    pageInfo { hasNextPage endCursor }
  }
}
```

Repeat until `hasNextPage` is `false`.

> [!TIP]
> Keep page sizes moderate and only select the fields you need — smaller responses are faster.
