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

Make cache parameter optional when no caching is needed ! #4434

Closed
safizn opened this issue Feb 12, 2019 · 2 comments
Closed

Make cache parameter optional when no caching is needed ! #4434

safizn opened this issue Feb 12, 2019 · 2 comments

Comments

@safizn
Copy link

safizn commented Feb 12, 2019

Hi, I chose to use apollo-client for my Nodejs build scripts, basically retrieving the latest release from a Github repository and pushing new releases.
I like the architecture of the module where different concerns are separated and pluggable (network protocol, caching implementation, etc.), but I find it strange that caching is mandatory, while at the same time the policy option for no-cache is available. What about treating undefined apollo-client cache option as if no-cache policy is on ?

Current implementation:

import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'

const defaultOptions = {
  watchQuery: {
    fetchPolicy: 'no-cache',  // 🙀
    errorPolicy: 'ignore',
  },
  query: {
    fetchPolicy: 'no-cache',  // 🙀
    errorPolicy: 'all',
  },
  mutate: {
    errorPolicy: 'all'
  }
}

const client = new ApolloClient({
  link: new HttpLink(),
  cache: new InMemoryCache(),  // 🙀
  defaultOptions 
})

Suggested implementation:

import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'

const client = new ApolloClient({
  link: new HttpLink(),
  cache: null  // 👌will result in `no-cache` default options for both `query` and `watchQuery`.
})
@danilobuerger
Copy link
Contributor

Thanks for your interest in helping make Apollo Client better!

Feature requests and non-bug related discussions are no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests.

@safizn
Copy link
Author

safizn commented Feb 12, 2019

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 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

No branches or pull requests

2 participants