send error not connection_error on query validation errors (fix #1790) (#1792)

This commit is contained in:
Anon Ray 2019-03-17 12:00:54 +00:00 committed by Vamshi Surabhi
parent df8216b576
commit 961f1af528

View File

@ -227,17 +227,15 @@ onStart serverEnv wsConn (StartMsg opId q) msgRaw = catchAndIgnore $ do
sc <- liftIO $ IORef.readIORef gCtxMapRef
(gCtx, _) <- flip runStateT sc $ getGCtx (userRole userInfo) (scGCtxMap sc)
res <- runExceptT $ runReaderT (getQueryParts q) gCtx
queryParts <- case res of
Left (QErr _ _ err _ _) -> withComplete $ sendConnErr err
Right vals -> return vals
eQueryParts <- runExceptT $ runReaderT (getQueryParts q) gCtx
queryParts <- either (withComplete . preExecErr) return eQueryParts
let opDef = qpOpDef queryParts
topLevelNodes = TH.getTopLevelNodes opDef
typeLocs = TH.gatherTypeLocs gCtx topLevelNodes
res' <- runExceptT $ TH.assertSameLocationNodes typeLocs
either (\(QErr _ _ err _ _) -> withComplete $ sendConnErr err) return res'
res <- runExceptT $ TH.assertSameLocationNodes typeLocs
either (withComplete . preExecErr) return res
case typeLocs of
[] -> runHasuraQ userInfo gCtx queryParts