这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions server/src-lib/Hasura/GraphQL/Transport/WebSocket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type OperationMap
data WSConnData
= WSConnData
-- the role and headers are set only on connection_init message
{ _wscUser :: !(IORef.IORef (Maybe UserInfo))
{ _wscUser :: !(IORef.IORef (Maybe (Either Text UserInfo)))
-- we only care about subscriptions,
-- the other operations (query/mutations)
-- are not tracked here
Expand Down Expand Up @@ -164,7 +164,9 @@ onStart serverEnv wsConn msg@(StartMsg opId q) = catchAndSend $ do

userInfoM <- liftIO $ IORef.readIORef userInfoR
userInfo <- case userInfoM of
Just userInfo -> return userInfo
Just (Right userInfo) -> return userInfo
Just (Left initErr) -> throwError $ SMConnErr $ ConnErrMsg $
"cannot start as connection_init failed with : " <> initErr
Nothing -> do
let err = "start received before the connection is initialised"
liftIO $ logger $ WSLog wsId $
Expand Down Expand Up @@ -261,10 +263,13 @@ onConnInit
onConnInit (L.Logger logger) manager wsConn authMode connParamsM = do
res <- runExceptT $ getUserInfo logger manager headers authMode
case res of
Left e ->
Left e -> do
liftIO $ IORef.writeIORef (_wscUser $ WS.getData wsConn) $
Just $ Left $ qeError e
sendMsg wsConn $ SMConnErr $ ConnErrMsg $ qeError e
Right userInfo -> do
liftIO $ IORef.writeIORef (_wscUser $ WS.getData wsConn) $ Just userInfo
liftIO $ IORef.writeIORef (_wscUser $ WS.getData wsConn) $
Just $ Right userInfo
sendMsg wsConn SMConnAck
-- TODO: send it periodically? Why doesn't apollo's protocol use
-- ping/pong frames of websocket spec?
Expand Down