nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

graphql-request - headers not passed correctly to the request method

Open leanpilar opened this issue 5 years ago • 3 comments

my setup module:

    GraphQLRequestModule.forRoot(GraphQLRequestModule, {
      endpoint: 'http://localhost:3165/graphql',
      options: {
        headers: {
          'content-type': 'application/json',
        },
      },
    }),

service:

  constructor(
    @InjectGraphQLClient() private readonly client: GraphQLClient,
  ) { }

method:

async getData() {
  ...
  const headers: Dom.RequestInit['headers'] = {var: 1}
  const res = await this.client.request(data, {}, headers);
  ...
}

but the request headers don't contain var I try tp follow the type value: request<T = any, V = Variables>(document: RequestDocument, variables?: V, requestHeaders?: Dom.RequestInit['headers']): Promise<T>; but can't make it work. Did I make some mistake??

leanpilar avatar Aug 07 '21 16:08 leanpilar

I also encountered this problem. It happens because the module uses an outdated version of "graphql-request": "^1.8.2", which only supports global headers.

PainteR avatar Oct 02 '21 21:10 PainteR

@leanpilar @PainteR fixed in @golevelup/[email protected]

WonderPanda avatar Oct 06 '21 12:10 WonderPanda

Getting this error again in @golevelup/[email protected]

ghost avatar Sep 15 '22 20:09 ghost