Diizzayy / nuxt-graphql-client

⚡️ Minimal GraphQL Client + Code Generation for Nuxt3
https://nuxt-graphql-client.web.app
MIT License
341 stars 42 forks source link

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

Open angelokeirsebilck opened 1 year ago

angelokeirsebilck commented 1 year ago

Environment

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