Skip to content

ref(tsc): insights useReleases to apiOptions#114411

Merged
TkDodo merged 2 commits intomasterfrom
tkdodo/ref/useReleases-to-apiOptions
May 4, 2026
Merged

ref(tsc): insights useReleases to apiOptions#114411
TkDodo merged 2 commits intomasterfrom
tkdodo/ref/useReleases-to-apiOptions

Conversation

@TkDodo
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo commented Apr 30, 2026

Migrate the insights useReleases hook from a manually-built v1 query key + custom api.requestPromise queryFn to apiOptions.as<TableData>()(...) wrapped in queryOptions(...).

The original was working around the absence of apiOptions by building [getApiUrl(...), {query}] and then re-deriving {url, options} via parseQueryKey to call api.requestPromise by hand. With apiOptions, the URL and options live in one place and the default selectJson returns TableData to the consumer — so the existing c.data?.data?.forEach access pattern below the useQueries call stays identical.

Drops now-unused imports: getApiUrl, parseQueryKey, ApiQueryKey, useApi. No behavior change.

Replace the manual `[getApiUrl(...), {query}]` v1 query key + custom
`api.requestPromise` queryFn with `apiOptions.as<TableData>()(...)` wrapped in
`queryOptions(...)`. The default `selectJson` returns `TableData` directly so
consumer access patterns (`c.data?.data`) remain unchanged.

Drops now-unused imports: `getApiUrl`, `parseQueryKey`, `ApiQueryKey`, `useApi`.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 30, 2026
@TkDodo TkDodo marked this pull request as ready for review April 30, 2026 12:03
@TkDodo TkDodo requested a review from a team as a code owner April 30, 2026 12:03
@TkDodo TkDodo requested a review from a team April 30, 2026 12:04
@TkDodo TkDodo merged commit 7256de9 into master May 4, 2026
67 checks passed
@TkDodo TkDodo deleted the tkdodo/ref/useReleases-to-apiOptions branch May 4, 2026 10:49
cleptric pushed a commit that referenced this pull request May 5, 2026
Migrate the insights `useReleases` hook from a manually-built v1 query
key + custom `api.requestPromise` queryFn to
`apiOptions.as<TableData>()(...)` wrapped in `queryOptions(...)`.

The original was working around the absence of `apiOptions` by building
`[getApiUrl(...), {query}]` and then re-deriving `{url, options}` via
`parseQueryKey` to call `api.requestPromise` by hand. With `apiOptions`,
the URL and options live in one place and the default `selectJson`
returns `TableData` to the consumer — so the existing
`c.data?.data?.forEach` access pattern below the `useQueries` call stays
identical.

Drops now-unused imports: `getApiUrl`, `parseQueryKey`, `ApiQueryKey`,
`useApi`. No behavior change.

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants