Repository navigation
Description
Part of v1.0.0 getsentry/sentry-api-schema#93. This is the first frontend adoption slice: use generated API contracts inside the existing apiOptions abstraction while retaining the frontend's current request execution.
Outcome
A schema-covered query should infer its inputs and response without repeating an SDK operation, writing a manual queryFn, or adapting errors in each component. Existing apiOptions.as<T>() calls remain supported.
Illustrative target API; this inferred signature does not exist today:
const query = useQuery(
apiOptions('/organizations/$organizationIdOrSlug/projects/', {
path: {organizationIdOrSlug: organization.slug},
staleTime: 30_000,
})
);The frontend already has a TODO to infer responses from an ApiMapping. Build on that seam rather than introducing a competing query API.
SDK-owned work
- Generate and export an aggregate operation map keyed by canonical endpoint and HTTP method, reusing generated input, success-response, and error types.
- Describe path/query/body inputs and preserve optionality, supported methods, and response unions. Avoid manual per-endpoint registration and casts.
- Keep contract consumption type-only where possible; importing the map must not pull in the runtime client, React, TanStack, or validators.
- Verify regeneration and type inference against representative read, mutation, and paginated operations, including a type-only import from the packed package.
Shared frontend integration
- Connect the map to
apiOptions/ infinite options once. Resolve the mapping from canonical OpenAPI routes and parameters to frontend$parameterroutes during generation or shared integration, never in each query. Verify aliases and ambiguous/missing matches. - Preserve existing call sites, query keys, invalidation,
skipToken,staleTime, selectors, and cache shape{json, headers, status?}. - Keep
apiFetch → Clientas the runtime path for this phase. It continues producing the actualRequestErrorand applying existing auth, sudo, routing, credentials, CSRF, and retry policies. No error conversion, WeakMap, constructor injection, or per-query adapter is needed for this phase. - Keep TanStack error typing honest: the map describes API response contracts, not an exhaustive checked exception channel. Do not globally declare that every query error is
SentryApiErrororRequestError. - Retain
.as<T>()for internal/getsentry endpoints absent from the public schema and for deliberate compatibility cases. Do not silently replace richer frontend types with incomplete public responses or publish private endpoints to eliminate the fallback. - Compile representative existing and inferred call sites, including unknown/private-route fallback; verify existing cache keys and selectors remain compatible.
Scope and sequencing
This can proceed alongside the transport foundation in getsentry/sentry-api-schema#94, getsentry/sentry-api-schema#95, getsentry/sentry-api-schema#92, and the auth/routing work. It does not require a generic TanStack plugin.
This is adoption of the SDK's schema/type contracts, not adoption of its runtime requests, retries, or pagination. It must not be used to mark the frontend runtime release gate complete. The subsequent runtime integration is tracked separately in #103.
The SDK team owns the generated contract and reusable integration support. A focused frontend PR connects the existing abstraction; feature teams should not write adapter code in their components.
Relationship to routing metadata
#81's backend routing-metadata work does not make this type-only phase depend on an SDK router. Keep canonical method/route identities compatible with that metadata, but retain apiFetch → Client and current frontend routing. Generated type inference must not silently select hosts, perform discovery or introduce a cache.
Activity
fix: stabilize SDK response and error contracts (#104)
fix: preserve cancellation before SDK fetch dispatch (#105)
feat: export a generated operation catalog (#110)
linear-code commentedon Nov 16, 2026
ENG-9054
feat(api): Add a type-only ApiRoutes map by path and method (#131221)