Then trying to create tests for custom headers, that can be added by implementing the RemoteGraphQLDataSource.willSendRequest(args) function, I noted that the args.request.http.header was undefined. From the examples in the documentation, one would expect that a request with any header would make request.http.header to be defined and then we could just use .set to add a custom header to be passed to the services.
Knowledge Gap
We don't know why the original request headers aren't available for the method willSendRequest. Is something misconfigured on the test server? Did I understand Apollo's documentation wrong?
Goals/Deliverables
[ ] Explain what causes the parameter of RemoteGraphQLDataSorce.willSendRequest() (the same as RemoteGraphQLDataSource.process()) to be undefined;
[ ] Understand how we can have the original headers on such parameters;
[ ] Update the test service configuration.
The type of .willSendRequest parameter is GraphQLDataSourceProcessOptions
Extra info
You can test sending any request to the test server by commenting/removing these lines
Spike/Research Request
Context
Then trying to create tests for custom headers, that can be added by implementing the
RemoteGraphQLDataSource.willSendRequest(args)
function, I noted that theargs.request.http.header
was undefined. From the examples in the documentation, one would expect that a request with any header would makerequest.http.header
to be defined and then we could just use.set
to add a custom header to be passed to the services.Knowledge Gap
willSendRequest
. Is something misconfigured on the test server? Did I understand Apollo's documentation wrong?Goals/Deliverables
RemoteGraphQLDataSorce.willSendRequest()
(the same asRemoteGraphQLDataSource.process()
) to be undefined;The type of
.willSendRequest
parameter isGraphQLDataSourceProcessOptions
Extra info
You can test sending any request to the test server by commenting/removing these lines
and adding a line with
console.log(gatewayService.address.port)
to know the gateway on thetest/index.ts
file. Then runyarn test
.