Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy style mutation hook #1602

Open
vicary opened this issue Aug 27, 2023 · 0 comments
Open

Proxy style mutation hook #1602

vicary opened this issue Aug 27, 2023 · 0 comments

Comments

@vicary
Copy link
Member

vicary commented Aug 27, 2023

Users want useMutation to work just like useQuery, not callback style like useLazyQuery.

We have been experimenting with proxy-style mutations in the past, during the early days of core v3 refactoring. Users tend to store proxy objects in states, when properties are being accessed in future renders, unexpected mutation fetches will happen, frequently so in some cases.

It is possible to allow the storage of stale accessors in states, by stripping their ability of triggering further fetches after the first fetch is happened.

  1. For queries and mutations, accessors are deep frozen into the respond data. That is, their ability to trigger fetches is removed after their first fetch.
  2. Caches are only read by accessors before their first fetch happens.
  3. Our current memo of context should be scrapped, do benchmarks if we actually re-create resolver contexts every single render.

Subscriptions should not be affected, since reconnection is always allowed and should not have side effects.


Originally posted by @hyusetiawan in #1601 (reply in thread)

@vicary for both modes, where do you get the variable mutation in the button onclick?

the API is rather awkward, I am sure there is an engineering reasoning behind it, is it not possible to do:

const {login} = useMutation()
const [mutation, state] = login

so it is more consistent with the useQuery?

@vicary vicary mentioned this issue Aug 27, 2023
8 tasks
@vicary vicary changed the title Transactional accessors Proxy style mutation hook May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant