migrate lazy queries to Apollo Client 4#2916
Conversation
…upgrade Apollo Client/Server, other libs that didn't support React 19 - Next.js 14.2.25 -> 15.5.14 - React 18.3.1 -> 19.2.4 - GraphQL 16.9.0 -> 16.13.2 - Apollo Client 3.11.8 -> 4.1.6 - Apollo Server 4.11.0 -> 5.5.0 - Apollo Server Integrations for Nextjs 3.1.0 -> 4.1.0 - \@yudiel/react-qr-scanner 2.0.8 -> 2.5.1 - qrcode.react 4.0.1 -> 4.2.0 - react-avatar-editor 13.0.2 -> 15.1.0 - recharts 2.13.0 -> 2.15.4 - react-is 19.2.4 override - can be removed after upgrade to recharts 3.x - eslint-plugin-next 14.2.15 -> 15.5.14 + eslint-config-next 15.5.14
…e boostrap sass deprecation warnings
… a server external DefinePlugin can't otherwise replace the env var internally used by next-plausible to determine if we're using the proxy or not
…get the full error where errors are manually handled
…pollo Client where unnecessary
…ents that by default use their own
…LOWED_DEV_ORIGINS env var for additional allowed origins
…inal Apollo Client 3 behavior (don't re-render components unless data changes)
- `index` state for navigation - `useQuery` skips when query is undefined - memoized suggestions
huumn
left a comment
There was a problem hiding this comment.
The main I issue I found with this was a regression in race conditions where successive queries can be executed and we need the last query rather than the last response (and we aren't debouncing otherwise). I'm not sure what the right move is, but we might want to establish some kind of abort/ignore pattern for these, debounce them (lowering the probability of races), or continue with useLazyQuery (which has the annoying abort pattern baked in).
territory-form.jswhen checking for an archived territory- e.g.
bitcoinis archived, I type outbitcointhenbitcoin1,bitcoin1returns available but then thebitcoinresponse comes later andbitcoin1is marked as archived
- e.g.
components/editor/plugins/upload.jshas a similar race
The other issue I found matched cursorbot's findings: suggestions and suggestions index can go out of sync now.
this is all bot review. by my eye it looks good - I would've missed the query races.
|
I couldn't reproduce without an artificial delay but this needs to be fixed anyway. We can probably keep I'll check where we need to switch back! edit:
It seems like everything else is textbook correct. |
…ok to stop concurrent queries (abort mechanism)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8676013. Configure here.

Description
Based on #2904
useLazyQuerys used outside of user interaction have the potential to throwAbortErrors much more frequently than before:We have some anti-patterns going on, some places should have
useQueryand other places should useclient.queryuseLazyQuery+useEffect: theexecuteis only ran byuseEffectand never reaches the user, can useuseQuerywithskipBaseSuggestcomponents/form.jsPostEditpages/items/[id]/edit.jsexecute: doesn't use any of the following:data,loading,errorand can useclient.querySubMultiSelectcomponents/sub-select.jsTerritoryFormcomponents/territory-form.jsuseCrosspostercomponents/use-crossposter.jsuseLexicalUploadFeescomponents/editor/plugins/upload.jsuseSuggestionscomponents/editor/plugins/mentions.jscomponents/payIn/hooks/use-auto-retry-pay-ins.jsWhile instead
sub-popover.js,item-popover.js,user-popover.js,link-form.js,wallets/.../logger.jsall useuseLazyQuerycorrectly.Additional Context
components/payIn/hooks/use-auto-retry-pay-ins.jspolls correctly every 30 seconds, but I didn't do deep QA.Checklist
Are your changes backward compatible? Please answer below:
Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
6, everything works smoothly, couldn't give it a 7 just because of missing QA on
components/payIn/hooks/use-auto-retry-pay-ins.jsDid you use AI for this? If so, how much did it assist you?
Plan
Note
Medium Risk
Changes several async data-fetch paths (editor mention suggestions, territory lookups, post edit fee line items, and pay-in retry polling) to avoid Apollo Client 4
AbortErrorbehavior; risk is moderate due to altered fetch timing/caching and error handling in user-facing and payment-related flows.Overview
Migrates multiple non-interactive
useLazyQueryusages to eitheruseApolloClient().query(one-off fetches) oruseQuerywithskip(effect-driven fetches) to reduce Apollo Client 4 in-flight cancellation/AbortErrorissues.This updates mention/autocomplete suggestion fetching, territory info lookups, crossposter item loading, and failed pay-in polling to use direct
client.querywith explicit fetch policies, and refactorspages/items/[id]/edit.jsto derive territory-add fee line items from aSUBSuseQueryresult instead of an effect + lazy query.Reviewed by Cursor Bugbot for commit f4fae62. Bugbot is set up for automated code reviews on this repo. Configure here.