How to pass different auth tokens for different specs?
spinningarrow opened this issue · comments
I'm using this library to wrap to different APIs and combine them into a unified graphql interface using express-graphql. I have two different specs, spec1.json
and spec2.json
and I'm able to create a schema by passing both of these to createGraphqlSchema
.
The problem is with authentication. spec1
uses OAuth and following the suggestion in #116 (comment) I have a separate express middleware that fetches the token and puts it in the request
object. When calling createGraphqlSchema
, I pass in the path to this using the tokenJSONPath
option.
On the other hand, spec2
uses a simple static API token which also goes into the Authorization
header and I set this using the headers
option in createGraphqlSchema
- first I check if the title matches spec2.info.title
and then I override this header.
However this seems not to work since the tokenJSONPath
always takes priority. Is there a way to work around this and essentially provide different authentication tokens to different specs?