apollographql / apollo-kotlin-compose-support

Compose support for Apollo Kotlin
https://apollographql.github.io/apollo-kotlin-compose-support/
MIT License
0 stars 0 forks source link

PagingSource invalidation #5

Open cvb941 opened 5 days ago

cvb941 commented 5 days ago

I'm trying to create PagingSources that seamlessly invalidate themselves on new data.

Currently, as I understand, the PagingSource only uses the CacheFirst policy and does not invalidate itself, which is required for FetchPolicies that can emit multiple responses.

It would be great to have a reference function in here that returns a properly invalidating PagingSource.

I'm not sure about the correct implementation though. The PagingSources are quite stateless and it is hard to avoid invalidating on repeated queries, with data coming in parts with possible errors and from the cache and network. Maybe the RemoteMediator is the correct solution as well.

BoD commented 4 days ago

Hi! Thanks for the insights!

Currently we call execute() on the calls returned by appendCall/prependCall - but we could call toFlow() (or more likely .watch()) instead in order to invalidate() when there are new emissions. Not 100% sure this would work well, but the nice thing is that it wouldn't change the current API.