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

No way to pass options to InMemoryCache constructor #7

Open
rejifald opened this issue Sep 4, 2022 · 0 comments · May be fixed by #8
Open

No way to pass options to InMemoryCache constructor #7

rejifald opened this issue Sep 4, 2022 · 0 comments · May be fixed by #8

Comments

@rejifald
Copy link

rejifald commented Sep 4, 2022

Problem
There is no way to neither pass cache options nor pass custom cache.

Scenario
In my particular scenario I need to pass possibleTypes to cache constructor.

Proposed solutions

  1. Allow user to pass path to the config file. For example:
export default defineNuxtConfig({
  apollo: {
        clientConfigs: {
            default: "@/apollo.client.js"
        }
  }
})

Where apollo.client.js file exports a function that returns client options see https://www.apollographql.com/docs/react/api/core/ApolloClient/#the-apolloclient-constructor.

For example:

import {InMemoryCache} from "@apollo/client";
import possibleTypes from "./possibleTypes.json"

export default () => ({cache: new InMemoryCache({ possibleTypes })})
  1. Allow to pass options into cache constructor.
    For example in your nuxt.config.js
{
       apollo: {
        clientConfigs: {
            default: {
                uri: "http://localhost:3000/api",
                // These options will be passed into InMemoryCache constructor
                cache: {
                   possibleTypes
                }
            },
}
@rejifald rejifald linked a pull request Sep 4, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant