useLazyQuery refetch

Can we change the fetchPolicy if we use the refetch? I have this kind of code
Screen Shot 2021-05-19 at 4.58.58 PM

Basically, it is using the default fetchPolicy, and would it be possible to change this policy once we use the refetch method so I can be able to fetch the latest data?

@hodormiso you can override the default fetch policy at any point with useLazyQuery by passing a new fetchPolicy into its options param.

useLazyQuery(GET_CATEGORY, { fetchPolicy: "..." })

You could add some code to decide which fetch policy to pass into the hook, depending on some other application state.

Another option is to consider using the nextFetchPolicy option. This will let you set a new fetch policy after the initial fetch has happened.

@hwillson , by default, I wanted to use the “cache-first” policy, and I want to override this policy if I use the pull to refresh on mobile, that is why I’ve set the refetch: categoryQueryDataRefetch.

If I execute categoryQueryDataRefetch, is there something like this that can override the default fetchPolicy

  fetchPolicy: 'no-cache',