Skip to content

feat(api): Infer apiOptions response types from backend contracts - #129593

Closed
billyvg wants to merge 1 commit into
billyvg/feat/api-contracts-generatedfrom
billyvg/feat/api-options-contract
Closed

billyvg wants to merge 1 commit into
billyvg/feat/api-contracts-generatedfrom
billyvg/feat/api-options-contract

Conversation

@billyvg

@billyvg billyvg commented Nov 2, 2026

Copy link
Copy Markdown
Member

Adds apiOptions.contract() and apiOptions.contractInfinite(). They take the response type from the generated ApiMapping (stacked on #129590), so callers no longer pass it by hand:

// before
apiOptions.as<Team[]>()('/organizations/$organizationIdOrSlug/teams/', {path, staleTime});
// after: the type is the response the backend declares for this route's GET
apiOptions.contract('/organizations/$organizationIdOrSlug/teams/', {path, staleTime});

They only accept routes whose GET declares a response type on the backend. Any other route fails typecheck instead of quietly becoming unknown, and stays on as<T>(). This PR changes no call sites.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 2, 2026
@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

ENG-8963

@billyvg
billyvg force-pushed the billyvg/feat/api-contracts-generated branch from 17d1fc8 to b5413db Compare November 3, 2026 20:44
@billyvg
billyvg force-pushed the billyvg/feat/api-options-contract branch from 5358ae3 to 1ecea65 Compare November 3, 2026 20:44
@billyvg
billyvg force-pushed the billyvg/feat/api-options-contract branch from 1ecea65 to f25d477 Compare November 3, 2026 21:05
@billyvg
billyvg force-pushed the billyvg/feat/api-contracts-generated branch from b5413db to 36eef60 Compare November 3, 2026 21:05
@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 780 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

Add apiOptions.contract() and contractInfinite(), which take the response type of a route's
GET from the generated ApiMapping instead of an explicit type argument. Routes without a GET
contract are rejected at typecheck; they stay on apiOptions.as<T>().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — d85b3117 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant