Hello. In our project, we have a fragment that displays a list of objects obtained through an Apollo query. Currently, we are using Apollo 2.5 with the CACHE_AND_NETWORK cache policy. When we make the query for the first time, the interface updates correctly. However, when there are changes in the data and we call the query again, the updated data never reaches the user interface. The fragment retains the cached data throughout its lifecycle. However, when we change the cache policy to NETWORK_FIRST, everything works correctly, and we can see the new data reflected in the fragment’s list. We have already verified the correct functioning of the fragment lifecycle, and we are using observers to listen for data changes. Are we missing something? Should we migrate to Apollo 3? We appreciate any help or guidance on this matter.
The CACHE_AND_NETWORK cache policy in Apollo 2.x does not provide the most up-to-date data to the consuming Fragment
Are you using Kotlin? If yes, updating to Apollo 3 is definitely the way to go. We’ll be able to provide better guidance and the APIs are much easier to use.
If that’s not something you can do in the short term, the best way to debug this is to share a small reproducer app. Without a reproducer, it’s really hard to tell. You can use the tutorial as a base: GitHub - apollographql/apollo-kotlin-tutorial: The code for the Apollo Kotlin Tutorial. The latest
main branch is using Apollo 3 but if you go back in the history, you’ll find a v2 version.