Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache-and-network to FetchPolicy options #4849

Closed
wants to merge 1 commit into from
Closed

Add cache-and-network to FetchPolicy options #4849

wants to merge 1 commit into from

Conversation

greggb
Copy link

@greggb greggb commented May 22, 2019

cache-and-network is a valid choice for fetchPolicy, and while it is documented, it is not part of the QueryOptions interface.
Screen Shot 2019-05-22 at 1 31 48 PM
Screen Shot 2019-05-22 at 1 38 44 PM

`cache-and-network` is a valid choice for fetchPolicy, and while it is documented, it is not part of the QueryOptions interface.
@benjamn
Copy link
Member

benjamn commented May 22, 2019

This was an intentional change in Apollo Client 2.6.0, discussed in #3130, and documented in CHANGELOG.md:

  • The FetchPolicy type has been split into two types, so that passing cache-and-network to ApolloClient#query is now forbidden at the type level, whereas previously it was forbidden by a runtime invariant assertion:
    export type FetchPolicy =
      | 'cache-first'
      | 'network-only'
      | 'cache-only'
      | 'no-cache'
      | 'standby';
    
    export type WatchQueryFetchPolicy =
      | FetchPolicy
      | 'cache-and-network';
    The exception thrown if you ignore the type error has also been improved to explain the motivation behind this restriction.

    Issue #3130 (comment) and commit cf069bc7

@benjamn benjamn closed this May 22, 2019
@benjamn
Copy link
Member

benjamn commented May 22, 2019

If you're using React Apollo, you may want to update to [email protected] (published this morning).

@apollo-cla
Copy link

@greggb: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@greggb
Copy link
Author

greggb commented May 22, 2019

If you're using React Apollo, you may want to update to [email protected] (published this morning).

Funny, this works just fine (using react-apollo-hooks), it's just the type def that shows an error. Thanks for pointing me to the correct thread.

@greggb greggb deleted the patch-1 branch May 22, 2019 19:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants