Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

TypeScript "network-and-cache" missing from useApolloClient's fetchPolicy options #3734

Open
alienfacepalm opened this issue Dec 6, 2019 · 1 comment

Comments

@alienfacepalm
Copy link

alienfacepalm commented Dec 6, 2019

The network-and-cache fetchPolicy type seems to be missing from TypeScript options for useApolloClient which is not the case with the useQuery hook.

export declare type FetchPolicy = 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby';

Is this intended? Why doesn't it match the types for useQuery hook?

Screen Shot 2019-12-06 at 1 28 42 PM

@dylanwulf
Copy link
Contributor

dylanwulf commented Dec 6, 2019

It's intentional: https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md#apollo-client-260-1

apollographql/apollo-client#3130 (comment)

basically: cache-and-network is not allowed on the one-shot query method because there's no way for a one-shot query to return more than one result. Therefore cache-and-network is only allowed for the watchQuery method (which is used by the useQuery hook). Try using the WatchQueryFetchPolicy type instead of the FetchPolicy type.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants