Skip to content

ref(api): Migrate view mutations to apiFetch - #127702

Closed
ryan953 wants to merge 8 commits into
masterfrom
ref/api-fetch-mutations-views
Closed

ryan953 wants to merge 8 commits into
masterfrom
ref/api-fetch-mutations-views

Conversation

@ryan953

@ryan953 ryan953 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Moves every fetchMutation call in static/app views outside settings to apiFetch, part of the stack that removes fetchMutation (see #127699 for the motivation). Mutations here now resolve to ApiResponse ({json, headers, status}), the same shape the query cache stores, so status and headers are available to them.

Most of the diff is a mechanical rewrite of fetchMutation({method, url, data, options}) to apiFetch({queryKey: [url, {method, data, ...options}]}). The hand edits are the consumers of the result: onSuccess handlers, mutateAsync callers, cache writes, and explicit useMutation generics now read or declare .json. Helpers with a body-typed public contract unwrap .json themselves so their callers stay unchanged.

Places worth a closer look, because TypeScript would not have flagged them:

  • buildComparison compared response.status to 'exists'; on ApiResponse that is the numeric HTTP status, so it now reads json.status.
  • useAssignIssueMutation handed its result to GroupStore through an any parameter.
  • useCreateGroupSearchView appended the mutation result to the starred-views cache.
  • The saveQuery callers unwrap .json so saveQueryModal keeps its {id} contract, which non-mutation callers share.

assigneeSelector lives in components but is in this PR, because it consumes useAssignIssueMutation.

Depends on #127699. Independent of the other area PRs; the cleanup PR that deletes fetchMutation merges after all of them.

No feature flags. No intended UI changes, so no screenshots.

apiFetch now accepts just {queryKey} rather than a full
QueryFunctionContext, so mutations can call it directly and resolve to
the same ApiResponse ({json, headers, status}) shape the query cache
uses. queryFn usage is unchanged, since a full context still satisfies
the narrower parameter; usePinnedLogsQuery built a context literal with
extra fields and now passes only the queryKey.

The mock API client now awaits a promise body when includeAllArgs is
set. apiFetch always sets it, so specs that hold a mutation in flight
with a promise body would otherwise receive the pending promise as json.
One preprod spec passed only because of that leak and now mocks a
resolved size analysis instead.
…iFetch

Mutations in static/app views now call apiFetch({queryKey: [url, {method, data}]})
and resolve to ApiResponse, the same {json, headers, status} shape the
query cache stores. Consumers that read the response body (onSuccess,
mutateAsync callers, cache writes, explicit useMutation generics) read
.json; status and headers are now available to them as well.

Helpers with a body-typed public contract unwrap .json at the helper so
their callers stay unchanged.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Narrowing the parameter to just queryKey meant apiFetch could never use other context fields, even though a mutation could supply them itself (for example its own AbortSignal). Keep queryKey required and accept the rest optionally, so queries pass the full context as before and mutations pass what they have. usePinnedLogsQuery can again pass its full context literal.
Mutations have no query context to forward, and the other QueryFunctionContext fields (signal, client, meta) describe a running query that a mutation would have to invent. Accept just the queryKey that both callers can supply. usePinnedLogsQuery built a context literal with extra fields and now passes only the queryKey.
Match apiFetch: destructure the two context fields the function reads instead of accepting the whole query context.
…nts PR

The spy targets linkProjectToRepository, which is migrated in the components PR.
Base automatically changed from ref/api-fetch-mutations-base to master October 16, 2026 17:30
@ryan953 ryan953 closed this Oct 16, 2026

This branch was successfully deployed

1 active deployment
Preview — 52e1b0b5 Deployed Oct 16, 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