Gomah / nuxt-graphql-request

Easy Minimal GraphQL client integration with Nuxt.js.
https://nuxt-graphql-request.vercel.app
MIT License
196 stars 16 forks source link

Client options are overriding each other #34

Closed drewbaker closed 3 years ago

drewbaker commented 3 years ago

So today I noticed that if you specify multiple clients, that the options for the second client become the options for all clients.

For example, here is the config I have:

/*
    graphql: {
        clients: {
            default: {
                endpoint: process.env.GQL_ENDPOINT,
                options: {
                    credentials: "include",
                    mode: "cors",
                },
            },
            shopify: {
                endpoint: process.env.SHOPIFY_ENDPOINT,
                options: {
                    credentials: "same-origin",
                    mode: "cors",
                    headers: {
                        "Content-Type": "application/json",
                        "X-Shopify-Storefront-Access-Token":
                            process.env.SHOPIFY_TOKEN,
                    },
                },
            },
        },
    },

The default client will actually send the headers that are defined in the Shopify client. Am I doing something wrong here? Or is this intended behavior?

I found this out because my default client is a CMS, and that server was complaining about the X-Shopify-Storefront-Access-Token being included in the request headers.

I noticed that if you change the order of the config, it's always the second one that overrides the first.

Gomah commented 3 years ago

Fixed in v4.2.1