-
Notifications
You must be signed in to change notification settings - Fork 738
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
Add refetchQueries to mutations #884
Comments
Interesting - this is one of the side effects of using the query path as the cache key by default. I'm tied up a bit at the moment in terms of adding it myself but I'd be more than happy to look at a PR for this! If you don't have bandwidth then note to self that this would probably be a good one to implement in concert with #192, query batching, since then we could send all the queries that need to be updated in one massive pile. |
I would love to implement this, I'll take a look today! |
I started on the PR and I ran into a couple of implementation questions. Where is the best place to add the logic for the refetch queries? I initially came up with this but I'm thinking I will need need some deeper changes.
One issue is that cancellables are being created for the queries but can't be used. So does that mean I should be thinking about a deep change to the requests? and the other problem is that queries are expected to be of one type. So I can't create an array of queries like this:
|
Right now for more advanced things like refetches we're just sort of dropping those cancellables on the floor (for example, when retrying in response to a retry delegate), so I don't think not returning those cancellables is the end of the world. One thing to watch out for is assuming that this feature will be used by everyone. Because of this, I think I think you're generally in the correct spot, but I think making sure that pieces that people may not want to use are optional is key here. |
Cool I can made the function:
as for creating queries So my assumption is that the only solution is type erasure? Am I correct on that assumption? |
I think if you just pass |
Looks like that doesn't work either. But it does work if there is only one query: looks like the issues come from |
@acarrera94 Please check out the RFC for the networking rewrite here: #1340 - that gives considerably more flexibility to what you can do with the networking stack, and would be curious to hear if you feel it can address the use case here sufficiently or not. |
Yes that should do it. The biggest issue was the the handling of associated types and generics. Looks like you're addressing that. I'm exited to contribute when it's closer! |
The apollo Android API has a modifier to a mutation called
refetchQueries
that takes a list of queries as arguments and refetches those queries after the mutations is completed. I would love to see this added to.perform
as an optional argument.Right now the alternatives are:
.fetchIgnoringCacheData
All of these work. We personally refetch the queries on our iOS project. But I feel like specifying which queries to refetch would lower the complexity of mutations. And we really liked using
refetchQueries
on the android side.The text was updated successfully, but these errors were encountered: