Skip to content

No way to pass options to InMemoryCache constructor #7

Open
@rejifald

Description

@rejifald

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
                }
            },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions