nhost-dart icon indicating copy to clipboard operation
nhost-dart copied to clipboard

NhostGraphQLProvider cache

Open MichalNemec opened this issue 3 years ago • 2 comments

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()),
    ),
  );

MichalNemec avatar Aug 23 '22 21:08 MichalNemec

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.

szilarddoro avatar Aug 24 '22 08:08 szilarddoro

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

MichalNemec avatar Aug 24 '22 22:08 MichalNemec

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

szilarddoro avatar Oct 11 '22 07:10 szilarddoro