Skip to content

fix(search-api-graphql): tell the caller which argument they got wrong - #737

Merged
ddeboer merged 1 commit into
mainfrom
worktree-issue-730-graphql-user-errors
Aug 14, 2026
Merged

fix(search-api-graphql): tell the caller which argument they got wrong#737
ddeboer merged 1 commit into
mainfrom
worktree-issue-730-graphql-user-errors

Conversation

@ddeboer

@ddeboer ddeboer commented Aug 14, 2026

Copy link
Copy Markdown
Member

Fix #730

Stacked on #728 (the IRI scalar this touches lives there); base retargets to main once that merges.

An out-of-range perPage (or page) was a plain Error thrown from a resolver, which graphql-yoga masks as "Unexpected error.". The sentence saying what was wrong survived only in the API container’s log – unreadable to a presentation-layer developer building against a hosted endpoint.

Changes

  • build-schema.ts – a userError() helper throwing a GraphQLError with extensions.code = 'BAD_USER_INPUT', used for the paging bounds and the IRI scalar’s coercion failure. The message now reaches the client, and the code lets a consumer tell “fix your query” from “retry later” without matching on prose. "Unexpected error." is left for faults nobody anticipated – an unreachable engine still masks as before.
  • SDL descriptions on every root-field argument, including the perPage bound (Results per page, between 0 and 100. …), so the playground’s own documentation answers where the boundary is before a request has to fail to say it. Complements feat(search-api-graphql): write the GraphQL contract of a schema module to a file #722.
  • Docs – a new “Errors the caller can fix” section in docs/reference/search-api-graphql.md, plus a note that both paging bounds are in the SDL.
  • Tests – a handler test asserting the message and code survive the transport (the direct-execution tests bypass masking, which is exactly where the bug lived), a counterpart asserting an engine failure still masks, and a code assertion on the existing paging-bounds test.

The generated SDL changes shape: arguments now carry descriptions, so printSchema breaks the root field over several lines. Snapshot updated; a consumer with its own contract snapshot will see the same diff.

@ddeboer
ddeboer changed the base branch from main to feat-iri-typed-filters August 14, 2026 10:09
@ddeboer ddeboer closed this Aug 14, 2026
@ddeboer ddeboer reopened this Aug 14, 2026
@ddeboer
ddeboer force-pushed the feat-iri-typed-filters branch 2 times, most recently from d653032 to af453bf Compare August 14, 2026 10:20
@ddeboer
ddeboer force-pushed the worktree-issue-730-graphql-user-errors branch from cffe872 to 686dbaa Compare August 14, 2026 10:41
Base automatically changed from feat-iri-typed-filters to main August 14, 2026 11:43
- throw a GraphQLError with extensions.code BAD_USER_INPUT for the
  paging bounds and the IRI scalar, so the transport keeps the message
  instead of masking it as "Unexpected error."
- describe every root-field argument in the SDL, stating the perPage
  bound where the playground shows it
@ddeboer
ddeboer force-pushed the worktree-issue-730-graphql-user-errors branch from 686dbaa to 4d5b903 Compare August 14, 2026 11:43
@ddeboer
ddeboer merged commit 0c72131 into main Aug 14, 2026
4 checks passed
@ddeboer
ddeboer deleted the worktree-issue-730-graphql-user-errors branch August 14, 2026 12:07
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.

Argument validation errors reach the client as "Unexpected error."

1 participant