You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
At this point the user has not logged in, there is no token. The websocket also has not yet connected, because lazy is set to true. It doesn't connect until until the first subscription has been sent, after the user has logged in.
When the user does log in, and the connection has been made, the authToken is null because this value was set when the client was configured, not after the user has logged in.
I can identify users this way because the token is added to the authorization header when the request has been sent after the user has logged in. The problem with the WebSocketLink connection params is that it reads the token when the client is being configured before the user has logged in.
The text was updated successfully, but these errors were encountered:
MoonTahoe
changed the title
Cannot identify subscription users once the WebSocketLink has been configured.
Cannot identify subscription users once the WebSocketLink has been configured.
May 17, 2018
I've been able to find a temporary solution. After the user is identified and their token is saved to the browser, I refresh the page: window.location = '/'. If feels so dirty though.
Any thoughts on adding onConnecting and onDisconnect methods to the constructor options of the WebSocketLink? This approach will prevent any need to refresh the page.
constwsLink=newWebSocketLink({uri: `ws://localhost:3333`,options: {onConnecting: ()=>{// Invoked just before the Socket initially connects// returns additional connection paramsreturn{authToken: localStorage.getItem('token')}},onDisconnect: ()=>{// Invoked when the socket is disconnected}}});
I'm having trouble identifying users who have connected with web sockets. Here is how you can reproduce this issue:
WebSocketLink
withconnectionParams
.At this point the user has not logged in, there is no token. The websocket also has not yet connected, because
lazy
is set to true. It doesn't connect until until the first subscription has been sent, after the user has logged in.When the user does log in, and the connection has been made, the
authToken
is null because this value was set when the client was configured, not after the user has logged in.Queries and Mutations are authorized by concatenating links:
I can identify users this way because the
token
is added to theauthorization
header when the request has been sent after the user has logged in. The problem with theWebSocketLink
connection params is that it reads the token when the client is being configured before the user has logged in.The text was updated successfully, but these errors were encountered: