List Objects

Introduction

Getting lists of objects is handled by the list<Object Name> mutation. For example: listEpisode.

Get Object List

Getting a list of objects using the list<Object Name> query takes the following input:

  • language: The language of the object to be returned
  • limit: The number of objects to be returned
  • next_token: Page token
  • ignore_availability: Coming soon

And the response has the following fields:

  • count: The number of objects in the result
  • next_token: The token for the next page of results. See pagination.
  • objects: The response objects

The objects field in the list response allows you to specify the return fields of objects in the response.

List Request

query listEpisode {
  listEpisode {
    count
    objects {
      uid
      title
      synopsis
    }
  }
}

Response:

{
  "data": {
    "listEpisode": {
      "count": 5,
      "objects": [
        ...
        {
          "uid": "3f3687dc-268d-4dcc-9a22-51db7b41cc99",
          "title": "Test episode 1",
          "synopsis": "This is a synopsis"
        }
        ...
      ]
    }
  }
}

Get Next Paginated Data Page

Responses from the list endpoint are subject to pagination.

If a further page of objects is available a next_token can be included in the response. This next_token can then be supplied to the next request for the next page of results.

If a further page is not available, the next_token will be returned as null.

Initial request:

query MyQuery {
  listEpisode {
    next_token
    objects {
      uid
      title
      synopsis
    }
  }
}

Initial response:

{
  "data": {
    "listEpisode": {
      "next_token": "<some next token>",
      "count": 10,
      "objects": [
        ...
        {
          "uid": "3f3687dc-268d-4dcc-9a22-51db7b41cc99",
          "title": "Test episode 1",
          "synopsis": "This is a synopsis"
        }
        ...
      ]
    }
  }
}

Subsequent request:

query MyQuery {
  listEpisode(next_token: "<next token from first request>") {
    objects {
      uid
      title
      synopsis
    }
    next_token
  }
}

Response:

{
  "data": {
    "listEpisode": {
      "next_token": null,
      "count": 8,
      "objects": [
        ...
        {
          "uid": "8c3705f4-6a6f-45ef-aa80-a53ec0d8b38b",
          "title": "Test episode 2",
          "synopsis": "This is another synopsis"
        }
        ...
      ]
    }
  }
}

Limit response size

All responses from the list<Object Name> response are limited on the number of results that are returned.

The default limit for a single page of objects is 10, and the default maximum is 50.

The user can change the limit to return more or less objects in a page, but attempted to get more than the maximum number of objects will just limit to that maximum.

Request:

query MyQuery {
  listEpisode(limit: 5) {
    objects {
      uid
      title
      synopsis
    }
  }
}

Response:

{
  "data": {
    "listEpisode": {
      "count": 5,
      "objects": [
        ...
        {
          "uid": "3f3687dc-268d-4dcc-9a22-51db7b41cc99",
          "title": "Test episode 1",
          "synopsis": "This is a synopsis"
        }
        ...
      ]
    }
  }
}