zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

Fix addResult not merging fresh result bug #1193

Closed dehypnosis closed 1 year ago

dehypnosis commented 2 years ago

Using FetchPolicy.cacheFirst sometimes makes useQuery stream's latestResult.timestamp newest. I didn't investigate further and don't know about detailed structure of QueryManager. But the practical problem is that while using fetchMore, cached result's timestamp is sometimes older than newly fetched result's timestamp in close different. (eg. less than 50ms.) That blocks new result being merged to query result.

In my usecase. In infinite scroll with CacheFirst query + and FetchMore strategy. The problem happens by turns:

https://github.com/zino-hofmann/graphql-flutter/blob/81028b307a4537faafce313430d68d61ff64b805/packages/graphql/lib/src/core/observable_query.dart#L253:L255 Made a change to above block to only compare latestResult from QueryResultSource.network

I made a local fix for my urgent project. And sorry for the lack of detail reproduction. But i hope you (who knows this project in deep level) can find out some potential problem from above description. Later if i had a time to reproduce it with simple code, i will attach that. For now, it would be please to take it as a simple bug report.

codecov[bot] commented 2 years ago

Codecov Report

Merging #1193 (827dc35) into main (7a84abb) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1193   +/-   ##
=======================================
  Coverage   59.61%   59.61%           
=======================================
  Files          41       41           
  Lines        1684     1684           
=======================================
  Hits         1004     1004           
  Misses        680      680           
Impacted Files Coverage Δ
...ackages/graphql/lib/src/core/observable_query.dart 38.34% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

budde377 commented 2 years ago

Can you try and elaborate on what you're experiencing and how you're using the library.

at first fetchMore attempt OK at second attempt: merge failed (nothing updated) at third attempt OK at fourth attempt merge failed

If you can add any more details to the above, e.g. timestamps, that would be great. How are you seeing that the "merge failed"?

vincenzopalazzo commented 1 year ago

Closing this due to lack of response!

I would be happy to reopen it!