graphql-request
graphql-request copied to clipboard
add parameter extendHeaders to function request and rawRequest
When the scenario follows:
const { GraphQLClient } = require('graphql-request')
class Test {
constructor (url, headers) {
// this.headers is a common section in each request
this.client = new GraphQLClient(url, {headers})
}
async excute (query, variables = null, headers = {}) {
// Each request has a different request header
// then setHeader
for (const [k, v] of headers) {
this.client.setHeader(k, v)
}
return this.client.request(query, variables)
}
}
However, When there is a lot of concurrency,the headers maybe messy