Skip to content

Lists: filter, sort, page, count and group

Every object type's list takes the same parameters, in REST (GET /<type>) and in GraphQL (<types> and <types>GroupBy): a where to choose the objects, an orderBy, and first and after to page through them. You can also count the objects a where matches, and group them with counts and aggregates. The syntax follows Prisma.

Every field of a type can be filtered on, nested fields and lists included, and so can the fields every object holds: id, url, at_type and meta ({"id": {"in": ["…", "…"]}} lists those objects). New and changed objects are listed within a few seconds of the write.

A page of objects

curl -G https://apis.objectsgrid.com/products \
  -H 'X-ObjectsGrid-AccessPoint: EU' \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode 'where={"color": "Blue", "offers": {"isEmpty": false}}' \
  --data-urlencode 'orderBy={"meta": {"createdAt": "desc"}}' \
  -d first=20
{
  "items": [{"id": "2b5f8f0e-…", "sku": "TRS-42", "color": "Blue"}],
  "pageInfo": {"endCursor": "eyJ…", "hasNextPage": true}
}
{
  products(where: {color: {equals: "Blue"}, offers: {isEmpty: false}},
           orderBy: [{meta: {createdAt: desc}}], first: 20) {
    items { id sku color }
    pageInfo { endCursor hasNextPage }
  }
}

For the next page, send the page's endCursor as after, with the same where and orderBy. hasNextPage tells whether another page follows. first is 1 to 100, 20 by default.

where

A where holds conditions on fields. All of them must hold; combine them with AND, OR and NOT (lists of wheres).

On Conditions
A string equals, in, notIn, lt, lte, gt, gte, contains, startsWith, endsWith, not; mode: insensitive ignores case
A number or a date-time equals, in, notIn, lt, lte, gt, gte, not
A boolean equals, not
A list of values (category, sameAs) has, hasSome, hasEvery, isEmpty
An embedded object (weight, aggregateRating) a where on its fields: {"weight": {"value": {"gt": 1}}}
A list of objects (name, offers of an OfferCatalog, tags) some, every, none (a where that one, every or no element meets), isEmpty

In REST, a bare value means equals: {"sku": "TRS-42"}. In GraphQL every condition is an object: {sku: {equals: "TRS-42"}}.

Localized text, such as name, is a list of LanguageTaggedStrings: a condition on one element holds for the same element's language, so this finds products named "Boot" in English, not those named "Boot" in German and something else in English:

{"name": {"some": {"at_value": "Boot", "at_language": "en"}}}

A Reference to another object takes conditions on its own fields, at_id, id and at_type: {"brand": {"id": {"equals": "0f0b9a52-…"}}}. A reference pinned to a version (…?version=<n>) matches its at_id without the version. A list of references takes some, none and isEmpty.

In REST, is and isNot put conditions on the referenced object's own fields: {"brand": {"is": {"name": {"some": {"at_value": {"equals": "Acme"}}}}}} finds the products of the brands named Acme, and {"orderItem": {"some": {"is": {"gtin13": {"equals": "4006381333931"}}}}} the orders of a product. The condition may match at most 1,000 referenced objects. GraphQL filters on a reference's own fields only; read the referenced objects through the reference instead.

A where holds at most 50 conditions, nested at most 5 levels.

orderBy

{"<field>": "asc"} or "desc", or a list of up to 3 of them. An embedded object's fields nest: {"meta": {"createdAt": "desc"}}. Lists can't be sorted on. The object's id always ends the order, so pages never overlap or skip an object.

In REST, a field can also say where objects without it go: {"<field>": {"sort": "asc", "nulls": "last"}} ("first" or "last"). GraphQL takes only asc or desc: orderBy: [{meta: {createdAt: desc}}].

Count

count=true adds totalCount, the number of objects the where matches:

curl -G https://apis.objectsgrid.com/products … --data-urlencode 'where={"color": "Blue"}' -d count=true -d first=1

Select totalCount:

{ products(where: {color: {equals: "Blue"}}) { totalCount } }

Groups

A groupBy groups the objects by 1 to 3 fields, and counts or aggregates each group: _count, _sum, _avg, _min and _max (sums and averages on numbers; minimum and maximum on numbers and date-times). having keeps the groups whose aggregates meet conditions (equals, gt, gte, lt, lte).

curl -G https://apis.objectsgrid.com/ratings … \
  --data-urlencode 'groupBy={"by": ["reviewAspect"], "_count": true, "_avg": {"ratingValue": true},
                             "having": {"ratingValue": {"_avg": {"gte": 4}}}, "orderBy": {"reviewAspect": "asc"}}'
{
  "groups": [{"reviewAspect": "comfort", "_count": 12, "_avg": {"ratingValue": 4.3}}],
  "pageInfo": {"endCursor": "", "hasNextPage": false}
}

A groupBy holds its own where, take (1 to 100, 20 by default) and cursor; it isn't combined with the where, orderBy, first, after or count parameters.

Select the counts and aggregates you want:

{
  ratingsGroupBy(by: [reviewAspect], having: {ratingValue: {_avg: {gte: 4}}}, orderBy: [{reviewAspect: asc}]) {
    groups { reviewAspect _count { _all } _avg { ratingValue } }
    pageInfo { endCursor hasNextPage }
  }
}

Groups are ordered by their by fields or, when grouping by one field, by an aggregate ({"_count": {"_all": "desc"}}).

Who may list what

Your ABAC policy decides each listed object: a page holds only the objects you may read, so a page can hold fewer than first objects while hasNextPage is still true. And:

  • A field hidden from you can't be used in a where, an orderBy or a groupBy: the list is refused with 400 and the field's name.
  • A count and a groupBy cover objects without returning them, so they need access to every object of the type: a policy that decides on each object (by its tags, say) refuses them with 401. List page by page instead. Administrators may always.

Mistakes

A where, orderBy or groupBy the type doesn't take is refused with 400, naming the part that's wrong, such as where.colour: unknown field or orderBy.sameAs: can't be sorted. In GraphQL, the schema itself refuses an unknown field.

from and size are gone: page with first and after. The query parameter (Elasticsearch Query DSL) was removed on 2026-11-20 and is refused with 400: use where and orderBy.