refactor(frontend): use client.mutate where useMutation result is unused#2338
Merged
Merged
Conversation
useMutation subscribes the component to the mutation's loading/data/error and
re-renders it while the request is in flight even when that state is never read.
Replace those call sites with useApolloClient().mutate(), which doesn't — the
guideline documented in apps/frontend/AGENTS.md.
Converted 31 call sites across 19 files (auth disconnects, level selects,
invites, ignore/unignore, comment composers, optimistic toggles, the review
action hook, …). Call-site variables/optimisticResponse/update/context move
into the single client.mutate({...}) call; DeleteAutomation's and the review
hook's onCompleted become .then(); BuildReviewAction stops returning its unused
mutation result (its one caller already ignored it).
The 25 useMutation usages that actually render from loading/data/error are left
as-is.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up cleanup from #2336: eliminate the
useMutation-without-result anti-pattern across the frontend.useMutationsubscribes the component to the mutation's ownloading/data/errorstate and re-renders it while the request is in flight even when that state is never read. Where a call site only needs to fire the mutation (it tracks pending itself, or not at all), that's wasted work. Those are replaced withuseApolloClient().mutate(), which doesn't subscribe.This is the guideline documented in
apps/frontend/AGENTS.md(added in #2336).Scope
31 call sites across 19 files converted — behavior preserved:
variables/optimisticResponse/update/contextfolded into the singleclient.mutate({ mutation, ... })object.DeleteAutomationand theuseCreateBuildReviewMutationhook:onCompleted→.then().BuildReviewActionno longer returns its unused mutation result (its one caller already destructured it away).Areas touched: auth disconnects (GitHub/GitLab/Google), Slack, GitRepository (unlink), SAMLSSO, contributor/member level selects, InvitesList, IgnoreButton, DeleteAutomation, comment composers (AddCommentForm, CommentCard, ScreenshotCommentLayer, DiffCommentLayer), optimistic toggles (CommentReactions, ReviewActivitySection subscribe, ReviewersSection request), and the review-action hook.
Left as-is: the 25
useMutationusages that genuinely render fromloading/data/error(dialogs with spinners, invite/verify screens, etc.).Verification
pnpm check-types— 0 errorspnpm lint— cleanpnpm check-format— cleanuseMutation(call reads its result state (verified by grep).🤖 Generated with Claude Code