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

Error: cache-and-network fetchPolicy can only be used with watchQuery #3880

Closed
wzup opened this issue Sep 4, 2018 · 21 comments
Closed

Error: cache-and-network fetchPolicy can only be used with watchQuery #3880

wzup opened this issue Sep 4, 2018 · 21 comments

Comments

@wzup
Copy link

wzup commented Sep 4, 2018

Any update on that?
#3130

Error: cache-and-network fetchPolicy can only be used with watchQuery

@ghost
Copy link

ghost commented Dec 28, 2018

having same issue with this.props.client.query, any workaround ?

@joelgetaction
Copy link

Bump. This is a serious issue for us and is preventing us from using Apollo properly ... Can somebody on the Apollo team please take a look at this?

Your documentation for query clearly states that cache-and-network is a valid value for this method, as per https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-config-options-fetchPolicy and https://www.apollographql.com/docs/react/api/apollo-client.html#ApolloClient.query . However, your master source is clearly throwing an error here https://github.com/apollographql/apollo-client/blob/master/packages/apollo-client/src/ApolloClient.ts#L283

Hey @hwillson any chance we can get some help with this? Or @peggyrayzis ? This is pretty urgent ... :-)

Thanks!

@oxbits
Copy link

oxbits commented Feb 11, 2019

i am also having this issue, has anything changed? is there a work around?

@zhangjing28
Copy link

same issue +1

@EwanValentine
Copy link

EwanValentine commented Feb 15, 2019

Same issue also +1 - having to use 'network-only' for queries currently. Apollo client version: 2.4.6

@maziarz
Copy link

maziarz commented Feb 18, 2019

Same here. network-only is really bad for optimistic UI.

@stoickeyboard
Copy link

Same issue +1

3 similar comments
@Zik42
Copy link

Zik42 commented Feb 23, 2019

Same issue +1

@mythfish
Copy link

Same issue +1

@alexandrecanuto
Copy link

Same issue +1

@yadianf
Copy link

yadianf commented Feb 26, 2019

same issue +1 :(

@EwanValentine
Copy link

I found you can use watchQuery, like the error suggests. Which works similarly to query anyway. But it'll let you do cache-and-network too.

@BahaaZidan
Copy link

same issue

@dustinbrink
Copy link

same issue +1

@rares-lupascu
Copy link

same issue 👍 ... wtf :/

@Guiradi
Copy link

Guiradi commented Mar 29, 2019

Same issue +1

@PowerKiKi
Copy link
Contributor

@wzup please close this issue as it is an exact duplicate of #3130, which you mentioned yourself. The discussion should not be spread across different threads.

@ongmap
Copy link

ongmap commented Sep 24, 2020

using this work for me
options: () => ({
fetchPolicy: 'cache-and-network'
})

fetchPolicy: 'cache-and-network' -> not work

I don't know why

@igorthurow
Copy link

Thanks @kismib! Better than use watchQuery for my scenario.

@tarasov-gk
Copy link

  • 1

@zhuhang-jasper
Copy link

The reason why cache-and-network is not accepted for query is explained here:
#3130 (comment)

@apollographql apollographql locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests