这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions server/src-lib/Hasura/GraphQL/Resolve/LiveQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Hasura.GraphQL.Resolve.LiveQuery
, LiveQueryMap
, newLiveQueryMap
, addLiveQuery
, TxRunner
, removeLiveQuery
) where

Expand Down
20 changes: 10 additions & 10 deletions server/src-lib/Hasura/GraphQL/Transport/WebSocket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import Hasura.EncJSON
import Hasura.GraphQL.Context (GCtx)
import qualified Hasura.GraphQL.Execute as E
import qualified Hasura.GraphQL.Resolve as R
import Hasura.GraphQL.Resolve.Context (LazyRespTx)
import qualified Hasura.GraphQL.Resolve.LiveQuery as LQ
import Hasura.GraphQL.Transport.HTTP.Protocol
import Hasura.GraphQL.Transport.WebSocket.Protocol
Expand All @@ -47,8 +46,6 @@ import Hasura.Server.Utils (bsToTxt)
-- uniquely identifies an operation
type GOperationId = (WS.WSId, OperationId)

type TxRunner = LazyRespTx -> IO (Either QErr EncJSON)

type OperationMap
= STMMap.Map OperationId LQ.LiveQuery

Expand Down Expand Up @@ -124,7 +121,7 @@ data WSServerEnv
= WSServerEnv
{ _wseLogger :: !L.Logger
, _wseServer :: !WSServer
, _wseRunTx :: !TxRunner
, _wseRunTx :: !LQ.TxRunner
, _wseLiveQMap :: !LiveQueryMap
, _wseGCtxMap :: !(IORef.IORef SchemaCache)
, _wseHManager :: !H.Manager
Expand Down Expand Up @@ -233,11 +230,14 @@ onStart serverEnv wsConn (StartMsg opId q) msgRaw = catchAndIgnore $ do
runHasuraGQ userInfo gCtx rootSelSet =
case rootSelSet of
V.RQuery selSet ->
execQueryOrMut $ R.resolveQuerySelSet userInfo gCtx sqlGenCtx selSet
execQueryOrMut $ withUserInfo userInfo $
R.resolveQuerySelSet userInfo gCtx sqlGenCtx selSet
V.RMutation selSet ->
execQueryOrMut $ R.resolveMutSelSet userInfo gCtx sqlGenCtx selSet
execQueryOrMut $ withUserInfo userInfo $
R.resolveMutSelSet userInfo gCtx sqlGenCtx selSet
V.RSubscription fld -> do
let tx = R.resolveSubsFld userInfo gCtx sqlGenCtx fld
let tx = withUserInfo userInfo $
R.resolveSubsFld userInfo gCtx sqlGenCtx fld
let lq = LQ.LiveQuery userInfo q
liftIO $ STM.atomically $ STMMap.insert lq opId opMap
liftIO $ LQ.addLiveQuery runTx lqMap lq
Expand Down Expand Up @@ -271,7 +271,6 @@ onStart serverEnv wsConn (StartMsg opId q) msgRaw = catchAndIgnore $ do
either postExecErr sendSuccResp resp
sendCompleted


WSServerEnv logger _ runTx lqMap gCtxMapRef httpMgr _ sqlGenCtx = serverEnv

wsId = WS.getWSId wsConn
Expand Down Expand Up @@ -416,11 +415,12 @@ onClose logger lqMap _ wsConn = do
createWSServerEnv
:: L.Logger
-> H.Manager -> SQLGenCtx -> IORef.IORef SchemaCache
-> TxRunner -> CorsPolicy -> IO WSServerEnv
-> LQ.TxRunner -> CorsPolicy -> IO WSServerEnv
createWSServerEnv logger httpManager sqlGenCtx cacheRef runTx corsPolicy = do
(wsServer, lqMap) <-
STM.atomically $ (,) <$> WS.createWSServer logger <*> LQ.newLiveQueryMap
return $ WSServerEnv logger wsServer runTx lqMap cacheRef httpManager corsPolicy sqlGenCtx
return $ WSServerEnv logger wsServer runTx lqMap cacheRef
httpManager corsPolicy sqlGenCtx

createWSServerApp :: AuthMode -> WSServerEnv -> WS.ServerApp
createWSServerApp authMode serverEnv =
Expand Down