Description
Hi again, ( Promise this one should be the last one for now ;) )
I wonder if it is at all possible to have the ability to set the data of a query in advance, with local data that the client already have.
I'll explain,
Say I have a rest "api/dishes/{dishId}/createEmptyDishRecipe" that creates a Recipe object (and attaches it to the Dish object) and returns it.
once this POST request is fulfilled, I will update a query named getDish
assigning the id to relation field.
dispatch(api.util.updateQuery("getDish", dishId, draft => { draft.recipeId = newRecipe.id }))
Now, the problem is that I also want to set in advance the data for query getRecipe
with the newly created Recipe (a moment later the UI will navigate to a new Recipe screen) but since the recipe is new, and no one has ever observed the query getRecipe
with the new id, updateQuery
won't do anything, and prefetch is kind of a bummer since it means an extra request for something that I already have in my hand
// This is ignored since the getRecipe query with the args sent was never observed.
dispatch(api.util.updateQuery("getRecipe", newRecipe.id, draft => newRecipe))
Is there any available solution for this kind of behavior?
Thanks again.. :)