apollo-datasource-http
apollo-datasource-http copied to clipboard
[QUESTION]: onRequest and query
Hi,
I had a question in regards to this library.
In some cases I need to pass an authentication or query param that I need to fetch from another source.
I tried to pass that in the request.query
and I noticed that it does not get added to the path since the build query is done prior to calling onRequest.
Is this intended behavior?
How do you guys handle such scenarios? I just want to make sure I am using it properly.
You should manipulate request.path
directly in onRequest
.
In my situation, to sign the query string with a function:
protected async onRequest(request: Request): Promise<void> {
request.path = request.path.split('?')[0] + '?' + sign(request.query)
}
I have made the argument of onRequest
to be Dispatcher.RequestOptions
which doesn't include query
field.
User will have no access to request.query
and have to manipulate the query string in request.path
.
It should avoid this issue happen in the future.