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?

1
  • 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: pub.dev/documentation/graphql/latest/graphql/… Commented May 29, 2021 at 11:05

1 Answer 1

-1
final GraphQLCache cache = GraphQLCache(
  dataIdFromObject: uuidFromObject,
);
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.