-
Notifications
You must be signed in to change notification settings - Fork 737
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
Query watcher not being called when cache is updated on an element by another query/subscription/mutation #1422
Comments
To add more to this, I feel like this is not related to collections only. If you have 1 query that watches something, then another query/mutation updates this cache indirectly (not using the same query, but another query that contains the same element with the same |
Do you have any thoughts on why the test that was added would be passing, but what you're working with would not be working? |
I'm afraid no, but all I can tell is that it works with 0.32.0 and not with 0.34.0 |
Hi @designatednerd, I think I have the same problem but not on a collection. My watcher is not triggered anymore since I have updated Apollo from 0.31.0 to 0.34.1. I have a watcher in cachePolicy .returnCacheDataAndFetch on this Query.
And I have a mutation that updates my cache and normally triggers my watcher.
Since my Apollo pod upgrade, not working anymore. My watcher is not triggered when mutation payload updates my cache. |
This is also occurring for me. 0.33.0 (non beta) worked; but not 0.34.0 or 0.34.1 |
@dhritzkiv That makes sense, the network stack and how it interacts with the cache changed completely in 0.34.0. Apologies, I've been under the weather. I'm gonna do some digging starting tomorrow to try to figure out how I broke this without breaking the tests 🙃 |
No rush from me! I was able to roll back to 0.33.0 no problem |
I can wait 1 week to have feedback from you @designatednerd on this issue. |
Same here, I rollbacked to 0.32.1 so no rush from me, and thanks for taking time investigating this! |
I'm trying to reproduce this issue to investigate what could be going on, but it's been hard because unfortunately our tests aren't set up to run in real life conditions, where concurrency may play a role. The existing watcher tests all continue to pass, and so do some new ones I've been adding. It would be helpful to learn more about the way people who experience this are using the framework, and what behavior they are seeing:
I know this is a long shot, but it would be even more helpful if anyone was able to share a project that reliably exhibits this issue. |
A few more thoughts after taking a closer look at this:
|
I'm not using WebSocketTransport, but 3. sound like it could be what's plaguing us! Will have some time in two weeks to poke around that |
@martijnwalraven I guess 3. could be an explanation in my case, I have a custom
becomes
I need to change
into
to try to conform my code to the new signature |
@designatednerd @martijnwalraven any progress? |
not yet - also, be aware that |
What? |
@Narayane @benoitletondor @dhritzkiv I think this should be resolved by |
@designatednerd A preliminary run using 0.37.0: it looks like the cache+watchers work as expected! Thanks. :) |
@designatednerd Still an issue in my case, watchers are not triggered in 0.37.0 with the code below in my custom
|
@Narayane Yeah, the caching on custom network transports is basically broken at the moment, so that would make sense. The current workaround is to write a custom interceptor for your network usage similar to the default Network interceptor but using your own networking. I'm working on a longer-term fix but this is something that was missed through the RFC and Beta processes so there's a decent amount of rethinking that needs to be done there, unfortunately 😭 |
Hi @designatednerd, any progress on my problem? It begins to be disturbing to be stuck in v0.33 since v0.39 is the current... |
At this point the recommended workaround remains creating your own custom network interceptor and using the This is definitely something that needs to be revisited but at this point i think the workaround is sufficient that it'll be better long-term to do it as part of enhancements to the chain system that will make it easier to use this stuff for all network requests (including, hopefully, web sockets). |
@designatednerd Ok, I don't have time for the moment but I would try. Do you know any example I could follow to help me? |
Hi all, Is there a recommended way to deal with the subscriptions from the |
In my current implementation of
I could make out cases like not an httpResponse (client or server timeout)
I guess I can make out anymore now, with this code above, |
If you're using our
Does that help? |
I don't know if I am currently using an
Your other answers help me, yes. |
You are not if you're providing the alternate network transport. |
Is it ok if I follow this to make evolve the way I build my custom Apollo client for resolving my watchers trigger problems with v0.34+? |
I'm not quite sure what the question is here - that is currently the recommended setup. Can you clarify a bit what the question is? |
Hi @designatednerd, Seems to solve my watchers trigger problems with v0.41.0, I just had the same problem than him with custom Thanks for your support :) |
Taking the occasion to jump again on the conversation. Please let me know when you have news around the Many thanks! |
Planning on tackling this soon! |
@designatednerd Do you have any updates on this issue? |
Thanks for the poke! Right now the main update is that we've had to roll back Starscream to an older version due to some crash issues a bunch of people were experiencing. We're looking at how to address this hole (and others in the current request chain implementation) in a more long-term way right now, but I don't have an ETA. Apologies for the back and forth on this. We've got another dev who's getting ramped up now, so I'm hoping we'll have a much better process and predictability around all this soon. |
After investigation, the issue is more about the type of transport, aka |
@designatednerd what should be the difference between our own |
Bug report
Query watcher not being called when cache is updated on an element of a collection that is added after calling watch
Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 0.34.0Steps to reproduce
I've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a
watch
on a query that returns the list of conversations, this is something like that:So the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that
It works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.
After investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the
unreadMessagesCount
to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one.So it really seems like
watch
is not being called again for changes on an item that wasn't in a collection when thewatch
was initially made. I've also take a look at #281 and making afetch
on the same query again after the event doesn't fix the issue.Let me know if I'm not clear on something as the whole thing is a bit complicated to explain.
The text was updated successfully, but these errors were encountered: