Closed younisshah closed 7 years ago
Are you using React? If so, it's like this: http://dev.apollodata.com/react/api.html#graphql-query-options\.fetchPolicy
BTW the best place to ask questions is Stack Overflow with the apollo
tag: http://stackoverflow.com/questions/tagged/apollo
@stubailo Thanks for the quick reply. I'm using React Native. I had already checked the API doc for fetchPolicy
but I couldn't get it to run. Can you please provide a simple example here? Much appreciated!
I couldn't get it to run
Can you post the code you tried? Are you using the newest version of Apollo Client?
@stubailo I have a use-case wherein I need access to ApolloClient
so I used withApollo
. Here is a snippet
let response = await apolloGraphQLClient.query({
query: generateOTPQuery,
variables: {"CountryCode": this.countryCode, "MobileNumber": this.mobileNumber},
options: {fetchPolicy: 'network-only'}
});
What am I doing wrong?
ah - you don't need the extra options
:
let response = await apolloGraphQLClient.query({
query: generateOTPQuery,
variables: {"CountryCode": this.countryCode, "MobileNumber": this.mobileNumber},
fetchPolicy: 'network-only'
});
@stubailo I tried it as well, but it doesn't work! :(
@younisshah it would help if you followed the issue template and described exactly what you're doing (ideally with relevant code), what you expect to happen, and what you observed instead. "It doesn't work" isn't useful information for us to help you. You should instead tell us how you determined that "it's not working", i.e. tell us what you did, what you expected to happen, and what you saw instead.
Hi,
the same is with me. "fetchPolicy" does not work, I get always the cached data until I reload the page.
export default connect(mapStateToProps)(reduxForm({
form: 'eventform',
destroyOnUnmount: false,
})(graphql(query, {
options: (props) => ({
forceFetch: true,
fetchPolicy: 'network-only',
variables: {
eventId: props.eventId,
},
}),
})(new CSSModules(CreateEventFormPage1, styles, { allowMultiple: true }))));
Something wrong?
Thanks for your help!
@semy @younisshah I'm going to close this issue here, because this is a wrong repo. Please open an issue on react-apollo
or Apollo Client, depending on which one you're using. Please also follow the issue template there and provide a clear description of what you're doing and what you're observing.
Ran into the same issue, but an upgrade solved it: apollo-client@1.0.0-rc.9
and react-apollo@1.0.0-rc.3
refetch the component's query every time.
Works for me on 1.0.0-rc.9, but stops working on 1.0.2
How can I set the
fetchPolicy
tonetwork-only
? I can't understand how to do it!