Open ghost opened 2 years ago
I'd also be willing to open a pull request for this change.
Would this help?
import { setContext } from '@apollo/client/link/context'
const link = ApolloLink.from([
setContext((request, previousContext) => {
return {
headers: {
...previousContext.headers,
//Your own headers here
}
}
}),
//Other links here
])
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
I have an interesting use-case where I need to pass along additional request headers to a
subscription
endpoint to trigger some logic in the corresponding request resolver. My subscription uses IAM auth, which results in the following payload:While my custom headers do get sent, they appear inaccessible once the resolver context is built and supplied to my resolver template. Instead, request headers are only available from the SigV4 headers sent in with the query string
?header="..."
Modifying
AppSyncRealTimeSubscriptionHandshakeLink._awsRealTimeIAMHeader
to include custom headers would resolve this problem, iff this is a reasonable use-case and I'm not missing some other avenue for accessing my headers.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
What is the expected behavior?
Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?