2

I just upgrade graphql_flutter version "3.1.0" to "5.0.0-nullsafety.5".

IDE has an exception: "The method 'OptimisticCache' isn't defined for the type 'GraphQLService'."

My code:

    ValueNotifier(
     GraphQLClient(
      cache: OptimisticCache(dataIdFromObject: typenameDataIdFromObject),
      link: link,
      defaultPolicies: DefaultPolicies(
        watchQuery: Policies(
          fetch: FetchPolicy.noCache,
        ),
        query: Policies(
          fetch: FetchPolicy.noCache,
        ),
        mutate: Policies(
          fetch: FetchPolicy.noCache,
        ),
      ),
    ),
  )

How to fix it?

Huu Bao Nguyen
  • 1,051
  • 2
  • 14
  • 40
  • 1
    Did you try to use a `GraphQLCache()`? It seems that you can specify through the `GraphQLCache()` instance that you want to use an OptimisticCache. See the documentation of graphql_flutter for GraphQLCache: https://pub.dev/documentation/graphql/latest/graphql/GraphQLCache-class.html – BLKKKBVSIK May 29 '21 at 11:05

1 Answers1

-1
final GraphQLCache cache = GraphQLCache(
  dataIdFromObject: uuidFromObject,
);
Larry Moore
  • 19
  • 1
  • 5
  • 2
    Please don't post only code as an answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Tyler2P Oct 16 '21 at 11:48