mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
parent
534f23d1a6
commit
85df9ac1e8
@ -257,8 +257,8 @@ onStop serverEnv wsConn (StopMsg opId) = do
|
||||
|
||||
onConnInit
|
||||
:: (MonadIO m)
|
||||
=> L.Logger -> H.Manager -> WSConn -> AuthMode -> ConnParams -> m ()
|
||||
onConnInit logger manager wsConn authMode connParams = do
|
||||
=> L.Logger -> H.Manager -> WSConn -> AuthMode -> Maybe ConnParams -> m ()
|
||||
onConnInit logger manager wsConn authMode connParamsM = do
|
||||
res <- runExceptT $ getUserInfo logger manager headers authMode
|
||||
case res of
|
||||
Left e ->
|
||||
@ -272,7 +272,7 @@ onConnInit logger manager wsConn authMode connParams = do
|
||||
sendMsg wsConn SMConnKeepAlive
|
||||
where
|
||||
headers = [ (CI.mk $ TE.encodeUtf8 h, TE.encodeUtf8 v)
|
||||
| (h, v) <- maybe [] Map.toList $ _cpHeaders connParams
|
||||
| (h, v) <- maybe [] Map.toList $ connParamsM >>= _cpHeaders
|
||||
]
|
||||
|
||||
onClose
|
||||
|
@ -44,7 +44,7 @@ data StopMsg
|
||||
$(J.deriveJSON (J.aesonDrop 3 J.snakeCase) ''StopMsg)
|
||||
|
||||
data ClientMsg
|
||||
= CMConnInit !ConnParams
|
||||
= CMConnInit !(Maybe ConnParams)
|
||||
| CMStart !StartMsg
|
||||
| CMStop !StopMsg
|
||||
| CMConnTerm
|
||||
@ -60,7 +60,7 @@ instance J.FromJSON ClientMsg where
|
||||
parseJSON = J.withObject "ClientMessage" $ \obj -> do
|
||||
t <- obj J..: "type"
|
||||
case t of
|
||||
"connection_init" -> CMConnInit <$> obj J..: "payload"
|
||||
"connection_init" -> CMConnInit <$> obj J..:? "payload"
|
||||
"start" -> CMStart <$> J.parseJSON (J.Object obj)
|
||||
"stop" -> CMStop <$> J.parseJSON (J.Object obj)
|
||||
"connection_terminate" -> return CMConnTerm
|
||||
|
@ -27,6 +27,16 @@ class TestSubscriptionBasic(object):
|
||||
ev = hge_ctx.get_ws_event(3)
|
||||
assert ev['type'] == 'connection_ack', ev
|
||||
|
||||
'''
|
||||
Refer: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md#gql_connection_init
|
||||
'''
|
||||
def test_init_no_payload(self, hge_ctx):
|
||||
obj = {
|
||||
'type': 'connection_init'
|
||||
}
|
||||
hge_ctx.ws.send(json.dumps(obj))
|
||||
ev = hge_ctx.get_ws_event(3)
|
||||
assert ev['type'] == 'connection_ack', ev
|
||||
'''
|
||||
Refer: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md#gql_connection_error
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user