nhost / nhost-dart

Nhost Dart & Flutter packages
https://nhost.io
MIT License
90 stars 33 forks source link

NhostGraphQLProvider cache #78

Closed MichalNemec closed 2 years ago

MichalNemec commented 2 years ago

Hello,

Based on the graphql_flutter, there is setting for cache, is it handled automatically or the setting is just missing?

// We're using HiveStore for persistence,
  // so we need to initialize Hive.
  await initHiveForFlutter();

....

  ValueNotifier<GraphQLClient> client = ValueNotifier(
    GraphQLClient(
      link: link,
      // The default store is the InMemoryStore, which does NOT persist to disk
      cache: GraphQLCache(store: HiveStore()),
    ),
  );
szilarddoro commented 2 years ago

Hey @MichalNemec!

This is what's used internally by the NhostGraphQLProvider: https://github.com/nhost/nhost-dart/blob/77cb2217705e738131aac484fb9f6e2dc1f5c9cf/packages/nhost_graphql_adapter/lib/src/create_client.dart#L54

It uses the default GraphQLCache with the default InMemoryStore which doesn't persist anything to the disk. We are not exposing this field through the provider, so you won't be able to change the type of the cache or the store at the moment.

Unfortunately I don't see any possible workarounds, so we'll need to fix this to let you configure the cache.

MichalNemec commented 2 years ago

Hey @MichalNemec!

This is what's used internally by the NhostGraphQLProvider:

https://github.com/nhost/nhost-dart/blob/77cb2217705e738131aac484fb9f6e2dc1f5c9cf/packages/nhost_graphql_adapter/lib/src/create_client.dart#L54

It uses the default GraphQLCache with the default InMemoryStore which doesn't persist anything to the disk. We are not exposing this field through the provider, so you won't be able to change the type of the cache or the store at the moment.

Unfortunately I don't see any possible workarounds, so we'll need to fix this to let you configure the cache.

You are golden, thank you very much, ill wait for the cache update

szilarddoro commented 2 years ago

I'm closing this issue, because the cache is already configurable through NhostGraphQLProvider. Thanks again @MichalNemec! 🙌🏼