-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support setting headers and credentials from context #36
Comments
That's a deliberate API divergence, you can set headers and credentials via context by using const authLink = new ApolloLink((operation, forward) => {
const viewerToken = getViewerToken()
if (viewerToken)
operation.setContext({
fetchOptions: {
headers: {
authorization: `Bearer ${viewerToken}`
}
}
})
return forward(operation)
}) |
OK! The workaround looks good to me. Would be great if this behaviour is documented. Thanks a lot! |
With |
Just upgraded and it's working well. Thanks! |
Currently
context.headers
are being ignored byapollo-upload-client
, which is different from the behaviour ofapollo-link-http
.See https://github.com/apollographql/apollo-link/blob/9fa5b4dc9cd67577fd118e1f437b2138fe3cd8eb/packages/apollo-link-http/src/httpLink.ts#L114-L119 ,
headers
andcredentials
from context should merge withfetcherOptions
.The text was updated successfully, but these errors were encountered: