-
Notifications
You must be signed in to change notification settings - Fork 462
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
RFC: Add transform functions in Graphcache's optimistic updater returned data #2272
Comments
I'm currently not super inclined to say that this is worth the added internal complexity 😅 It may lead to some confusion across all of our APIs (what doesn't and what does support transform functions?) and the associated burden associated with supporting it everywhere where it makes sense. Currently, the reason why I favour a simple API here is that it doesn't have to be visually more complex than this, if we assume that often it can come down to However, what I find a lot more interesting here for optimistic resolvers specifically is that if we do allow it it could solve a longstanding issue I see here with arguments. For instance, say a mutation needs to modify nested data, e.g. So, tl;dr I see a lot more value here in the "optimistic nested fields with arguments" case. The question is: how often does that come up and can't be simply implemented with an updater 🤔 On another topic, the above is basically just a reaction, however, I think the RFC isn't quite compelling yet, and hence it does allow me to read a lot into it 😅 In other words, I'm not sure I'd act on an RFC just yet if the argument for it that an existing way is just not to everyone's taste. |
@kitten came up with a bit similar need here: #2346 It's a question since I'm not sure if there is some idiomatic way to achieve what I'm trying to do or not. I think this and the question are both about the ease of reusing the existing state and I believe that in both cases some callback based approach would result in more robust and less error prone software. |
We forgot to mark this, but it's been resolved and implemented by: #2616 |
Summary
Would be cool if there would be an easy way to pick the previous value of an object and modify that optimistically. Now my code looks something like that:
Proposed Solution
Something like this:
This would make optimistic updates less verbose, probably less error prone and easier to read.
The text was updated successfully, but these errors were encountered: