Updating React Query Cache with Presigned URLs #10014
Unanswered
OtaniToshiyuki
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
setQueryData is not directly writing the response of registerImagePath or deleteImagePath
Instead, it writes a locally constructed object (newEntry) that includes a newly generated presigned URL
Questions
Does this approach violate the recommended usage of setQueryData?
Even though the presigned URL is generated by the server, it is not returned as part of the mutation response.
Is there a more idiomatic or recommended approach for handling presigned URLs with expiration, while avoiding unnecessary invalidation and regeneration?
https://tkdodo.eu/blog/practical-react-query#dont-use-the-querycache-as-a-local-state-manager
“Don’t use the query cache as a local state manager.
Use it only for optimistic updates or for writing data received from the backend.”
Beta Was this translation helpful? Give feedback.
All reactions