You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.
I've got a one use case I am having trouble with implementing using apollo-link-state.
Lets say I have a view which is displaying a list of images, in a sidebar, in a form of thumbnails and when you click on an image that image is shown enlarged in a main view.
I can accomplish this with a query to the server to get all images:
to the onClick event of every image and have selectedImage being updated inside of the cache via the selectImage resolver.
Then the main component would query selectedImage to find out which image should it display enlarged.
This part works.
What I am trying to do is to set the cache to the first image on every new GET_IMAGES query.
This will not work the way I would expect it, maybe not a right word. graphgl(SELECT_IMAGE, config) is not invoking mutation it is simply passing mutate prop to the Sidebar. I need to call it to invoke the mutation, for example in componentDidMout.
So is there a way to invoke a mutation automatically?
My example is a simple case just to demonstrate. What I have tried to explain here is that the apollo-link-state is missing a way to update its cache as reaction to some changes - result of a query for example. Without a need to render the component and calling mutation method in one of the lifecycle hook.
Hope this make sense.
The text was updated successfully, but these errors were encountered:
Another thing that comes to mind is implementation of options.update for the queries options when you use apollo-link-state. Then you could skip the mutation from the composition entirely and just use the options.update to specify what else you need updated in a cache as a result of the query.
I've got a one use case I am having trouble with implementing using
apollo-link-state
.Lets say I have a view which is displaying a list of images, in a sidebar, in a form of thumbnails and when you click on an image that image is shown enlarged in a main view.
I can accomplish this with a query to the server to get all images:
And display them in the sidebar.
Then I can attache the mutation:
to the
onClick
event of every image and haveselectedImage
being updated inside of the cache via the selectImage resolver.Then the main component would query
selectedImage
to find out which image should it display enlarged.This part works.
What I am trying to do is to set the cache to the first image on every new
GET_IMAGES
query.I could do this:
This will not work the way I would expect it, maybe not a right word.
graphgl(SELECT_IMAGE, config)
is not invoking mutation it is simply passingmutate
prop to theSidebar
. I need to call it to invoke the mutation, for example incomponentDidMout
.So is there a way to invoke a mutation automatically?
My example is a simple case just to demonstrate. What I have tried to explain here is that the
apollo-link-state
is missing a way to update its cache as reaction to some changes - result of a query for example. Without a need to render the component and calling mutation method in one of the lifecycle hook.Hope this make sense.
The text was updated successfully, but these errors were encountered: