imsujan276 / shopify_flutter

A flutter package that works as a bridge between your Shopify Store and Flutter Application
https://pub.dev/packages/shopify_flutter
MIT License
26 stars 27 forks source link

Changed Fetch Policy for `currentUser` Query. #69

Closed asadamatic closed 5 months ago

asadamatic commented 5 months ago

Using cache is important to reduce the load on APIs, and to reduce loading times, but for things that may change frequently during the runtime, it would be better to go with network-only policy.

The ShopifyConfig.fetchPolicy sets the policy for all the queries, so if you want to use cache for products and collections, you'll have to opt-in to cache-first policy for all the queries. In case of currentUser query, I think this policy is not good, as the user will update their profile from the app. Some updates can be handled locally, but others may result in inconsistent data.

To resolve this, I have hardcoded the fetchPolicy for the currentUser query, as FetchPolicy.networkOnly.