Authorizing websocket connection with connectionParams #263
-
Hello! const wsExecutor: Executor = ({ document, variables, context }) => {
const subscriptionClient = createClient({
url: WS_ENDPOINT,
webSocketImpl: ws,
connectionParams: {
headers: {
authorization: context?.req.headers.authorization
}
}
});
return observableToAsyncIterable({
... /* the same as in the example */
});
}; With that approach, I encountered a problem: connectionParams are not sent when the client connects to the server. Line 593 in 2160755 Is it intended behaviour? Is there any other way to pass authorization header to websocket connection? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You cannot provide custom headers to a WebSocket upgrade request. The Furthermore, please also read: graphql/graphql-over-http#140 (comment). |
Beta Was this translation helpful? Give feedback.
You cannot provide custom headers to a WebSocket upgrade request.
The
connectionParams
is thepayload
part of theConnectionInit
message inside an established WebSocket connection and is available on the server through theContext
. Read the "ws server and client auth usage with token expiration, validation and refresh" recipe for inspiration.Furthermore, please also read: graphql/graphql-over-http#140 (comment).