I'm using GraphQL code generator to create typescript types of my schema entities. When I use useQuery like below there is no problem;
const { loading, error, data } = useQuery<
FavoritesQuery,
FavoritesQueryVariables
>({
fetchPolicy: 'no-cache',
});
However, when I try lazy query like below, typescript compiler suffers;
const [loadFavorites, { called, loading, data }] = useLazyQuery<
FavoritesQuery,
FavoritesQueryVariables
>(Queries.FAVORITES_QUERY, {
fetchPolicy: 'no-cache',
});
Intellisense finds fetchPolicy and its value list while typing. But compiler generates below error;
Argument of type '{ fetchPolicy: string; }' is not assignable to parameter of type 'LazyQueryHookOptions<{ __typename?: "MainQuery"; } & { favorites: ({ __typename?: "FavoriteGType"; } & Pick<FavoriteGType, "id" | "name" | "category" | "description" | "commandText" | "lastUpdatedDate"> & { ...; })[]; }, FavoritesQueryVariables>'.
Object literal may only specify known properties, and 'fetchPolicy' does not exist in type 'LazyQueryHookOptions<{ __typename?: "MainQuery"; } & { favorites: ({ __typename?: "FavoriteGType"; } & Pick<FavoriteGType, "id" | "name" | "category" | "description" | "commandText" | "lastUpdatedDate"> & { ...; })[]; }, FavoritesQueryVariables>'. TS2345
89 | FavoritesQueryVariables
90 | >(Queries.FAVORITES_QUERY, {
> 91 | fetchPolicy: 'no-cache',
| ^
92 | });
How should I use fetchPolicy in useLazyQuery?
Thanks & regards