Diizzayy/nuxt-graphql-client

Using useGqlToken on specific client always sets the token on first/default client + token is used on both clients.

angelokeirsebilck opened this issue · 0 comments

Environment

  • Operating System: Darwin
  • Node Version: v18.13.0
  • Nuxt Version: 3.5.1
  • Nitro Version: 2.4.1
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: nitro, modules, components, imports, css, image, auth, runtimeConfig, build, fontLoader, i18n, vite, postcss
  • Runtime Modules: nuxt-font-loader@2.3.1, @nuxt/image-edge@1.0.0-27991759.1a5eea1, @vueuse/nuxt@9.13.0, @nuxtjs/i18n@8.0.0-beta.10, nuxt-graphql-client@0.2.27, @pinia/nuxt@0.4.7, @formkit/nuxt@1.0.0-beta.9-f64c966, @sidebase/nuxt-auth@0.5.0, nuxt-swiper@1.1.0
  • Build Modules: -

Describe the bug

I've got two clients setup in nuxt.config.

 "graphql-client": {
        clients: {
          craft: {
            host: "will be overwritten by .env",
          },
          bagisto: {
            host: "will be overwritten by .env",
          },
        },
      },

When I try the following:

 useGqlToken("jwt from backend", { client: "bagisto" });

It always sets the token on the first/default client (craft)

image

Switching bagisto to the first/default client does not fix this because the token set is used on both clients (craft and bagisto) even though it is only set for the bagisto client.

Expected behaviour

Token should get set on the bagisto client and only be used on this client.

UPDATE:

Manually setting the tokenStorage name on both clients fixed it. Still something wrong internally how/where the token gets set on the client.

        clients: {
          bagisto: {
            host: "will be overwritten by .env",
            tokenStorage: {
              name: "gql:bagisto",
            },
          },
          craft: {
            host: "will be overwritten by .env",
            tokenStorage: {
              name: "gql:craft",
            },
          },
        },

Reproduction

No response

Additional context

No response

Logs

No response