Fetching multiple items

Fetching multiple items

When you want to fetch multiple content items of a given type you can use the collection query type. As explained in the schema generation docs, the name of the fields is the Plural name of the content model from which they derive.

In the following example, we use a content model called Post, with a Plural name of Posts.

query {
  Posts( limit : 30 ) {
    items {
        _id
        _slug
        title
    }
  }
}

You can limit the number of content items returned by using the limit parameter. If you don't set this parameter, then 10 content items will be returned by default. To make your query more specific, consider including arguments from the following list.

To query content items of different models at the same time, please refer to Fetching multi-type collections.

Arguments

The following arguments are available or required when querying a collection:

argumenttyperequireddescription
localeStringfalseLocale of a content item. If no locale is set, the default locale will be used.
locales[String]falseOptional fallback locales.
sortSortInputTypefalseRead more in Sorting collections.
whereWhereInputTypefalseRead more in Filtering collections.

Preview vs Production

Prepr provides default access tokens, Preview and Production, each with the necessary permissions to serve your staging and production sites, respectively. Learn more about GraphQL permissions.

Was this article helpful?

We’d love to learn from your feedback