Return data from mutate
See original GitHub issueNow that mutate
support passing an async function to get the data it will be helpful to get that data as return value of mutate
.
const data = await mutate('/api/data', fetch('/api/data').then(res => res.json()))
// use data
This way if I want to use the data right now for something else I don’t need to use the old way of first fetch and await and then pass the data to mutate
and return it below.
const data = await fetch('/api/data').then(res => res.json());
mutate('/api/data', data)
// use data
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
An array (or a function that returns an array) that specifies which queries you want to refetch after the mutation occurs. Each array...
Read more >How do you get the return data from a mutation? #194 - GitHub
I see no way to get what the server has sent back after making a mutation.
Read more >Return Values and Object Mutations - Practical Data Science
But when we mutate an object, the newly mutated object won't be returned to us. Instead, the method will return either nothing (...
Read more >Mutation & Revalidation - SWR
mutate returns the results the data parameter has been resolved. The function passed to mutate will return an updated data which is used...
Read more >Create, modify, and delete columns — mutate • dplyr
Value · Columns from .data will be preserved according to the .keep argument. · Existing columns that are modified by ... will always...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think would be nice to have this interface as well:
Yeah, you should be able to mutate any key used in your app even if you don’t have the current data in the scope of your mutate call.