Graphql-flutter: Query widgets with FetchPolicy.cacheOnly don't update if contents initially not in cache

Created on 24 May 2019  路  4Comments  路  Source: zino-app/graphql-flutter

Describe the bug
If you create a Query widget with FetchPolicy.cacheOnly and that widget renders before the cache is populated with the corresponding key, the widget does not ever re-render. This does not occur when the value is already in the cache when the widget first renders.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Query widget with FetchPolicy.cacheOnly
  2. After the initial render of the Query widget (e.g. in initState), call client.query with the same QueryOptions

Expected behavior
The Query widget with FetchPolicy.cacheOnly should re-render whenever the cache is updated, regardless of whether the contents were in the cache at initial render.

Additional context
I think this may be related to #290.

bug cache

All 4 comments

I think this is probably because I'm throwing an exception if cacheOnly yields nothing, which:

  • prevents any kind of results from being placed on the stream blocking render
  • prevents query lifecycle from being updated

If I'm right, adding an optimisticResult with an OptimisticCache would be a viable workaround for now

@micimize I will try out the workaround!

I think I'm wrong, to some extent - the Exception gets caught and transformed into a GraphQLError

I think this is probably fixed in 4.0.0-beta.1 given the rebroadcasting rework. If @yunyu or anyone else still has this issue on v4 comment and I'll reopen

Was this page helpful?
0 / 5 - 0 ratings