graphql-request icon indicating copy to clipboard operation
graphql-request copied to clipboard

add parameter extendHeaders to function request and rawRequest

Open houkk opened this issue 6 years ago • 0 comments

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

houkk avatar Apr 28 '19 06:04 houkk