Skip to content

feat(search-api-graphql)!: group result pagination into a shared Pagination type - #673

Merged
ddeboer merged 1 commit into
mainfrom
feat/graphql-pagination-type
Jul 28, 2026
Merged

feat(search-api-graphql)!: group result pagination into a shared Pagination type#673
ddeboer merged 1 commit into
mainfrom
feat/graphql-pagination-type

Conversation

@ddeboer

@ddeboer ddeboer commented Jul 28, 2026

Copy link
Copy Markdown
Member

Groups the search result envelope’s pagination fields into a single shared Pagination type. Every ‹Type›SearchResult now serves items / pagination / facets:

type Pagination {
  total: Int!
  page: Int!
  perPage: Int!
}

Why

  • Fragment reuse: total/page/perPage were stamped into every per-type result type, so a client pager could not share one fragment across root types. With one shared type, fragment Pager on Pagination { total page perPage } serves them all.
  • Extensibility: derived conveniences (totalPages, hasNextPage) get an obvious home later, instead of piling onto the result root next to items and facets.

The request arguments deliberately stay flat (page, perPage): GraphQL has no input fragments, so a pagination input object would add nesting without the reuse payoff. A Relay-style connection was considered and rejected – Typesense is natively offset-based, so cursors could only wrap offsets without cursor-stability guarantees, and a page-numbered faceted search UI wants totals and arbitrary page jumps (see ADR 3/4).

Changes

  • build-schema.ts: build one shared Pagination object type; nest the applied pagination in the resolver result.
  • Tests: queries and assertions updated; SDL stability snapshot regenerated; new assertion that Pagination is emitted once and referenced by every result type.
  • Docs: result-envelope description in the search-api-graphql reference, sample queries in the build-a-search-api guide, and the ADR 4 SDL sketch (including the flat-arguments rationale).

Breaking change (minor bump under the zero-major scheme): clients selecting total, page or perPage at the result root must select pagination { total page perPage } instead. Known downstream: LOL’s search frontend and guide queries.

…nation type

- serve items / pagination / facets: total, page and perPage now live in one
  Pagination object shared across every TypeSearchResult, so a single client
  pager fragment serves all root types
- keep the page and perPage arguments flat: GraphQL has no input fragments,
  so an input object would group them without the reuse payoff
- update the reference docs, the build-a-search-api guide and the ADR 4 SDL
  sketch accordingly

BREAKING CHANGE: the result envelope fields total, page and perPage moved
into a pagination object; select pagination { total page perPage } instead.
@ddeboer
ddeboer enabled auto-merge (squash) July 28, 2026 19:22
@ddeboer
ddeboer merged commit f7d01a5 into main Jul 28, 2026
4 checks passed
@ddeboer
ddeboer deleted the feat/graphql-pagination-type branch July 28, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant