CDA/API not returning all matching single-link filter

Simple scenario. i have a 417 of a collection pointing with a single link to a record in a different colleciton. in the dashboard, if i add a filter for this field i get the whole 417. in the cda/api they are not returned for the same field requested, only 20.

@lorenzo.larghi

The dashboard keeps fetching the next pages behind the scenes until it has all 417 results, while the Content Delivery API returns 20 items by default unless you ask for more. On the CDA you control page size with the first argument and the offset with skip. Default is 20, and you can request up to 500 per call. Docs here: https://www.datocms.com/docs/content-delivery-api/pagination

If your model has a single-link field pointing to that other record, filter with eq using the target record ID, and bump the page size so you actually get all 417 in one response. For example:

query {
  allArticles(
    filter: { relatedRecord: { eq: "TARGET_RECORD_ID" } }
    first: 500
  ) {
    id
    title
  }

  _allArticlesMeta(filter: { relatedRecord: { eq: "TARGET_RECORD_ID" } }) {
    count
  }
}

That will return up to 500 items at once, which covers your 417. The _allArticlesMeta { count } lets you confirm how many there are under the same filter so you can paginate deterministically. Same idea works for any model. Reference for filtering by links is here: https://www.datocms.com/docs/content-delivery-api/filtering-records

If you prefer true paging, call the same query multiple times changing skip: 0, 500, 1000, and so on, or use smaller pages like first: 100 with skip: 0, 100, 200.... The pagination docs show both first and skip in practice: https://www.datocms.com/docs/content-delivery-api/pagination

If you are fetching very large sets often and want to avoid writing the paging loop yourself, our tiny helper client can split oversized queries for you. See executeQueryWithAutoPagination in https://github.com/datocms/cda-client/tree/main?tab=readme-ov-file