morpheus-graphql-subscriptions 0.28.1 → 0.28.2
raw patch · 7 files changed
+45/−38 lines, 7 filesdep ~bytestringdep ~transformersdep ~unliftio-core
Dependency ranges changed: bytestring, transformers, unliftio-core, unordered-containers, uuid
Files
- morpheus-graphql-subscriptions.cabal +7/−7
- src/Data/Morpheus/Subscriptions.hs +4/−4
- src/Data/Morpheus/Subscriptions/Apollo.hs +23/−16
- src/Data/Morpheus/Subscriptions/ClientConnectionStore.hs +1/−1
- src/Data/Morpheus/Subscriptions/Internal.hs +2/−2
- src/Data/Morpheus/Subscriptions/Stream.hs +3/−3
- src/Data/Morpheus/Subscriptions/WebSockets.hs +5/−5
morpheus-graphql-subscriptions.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.38.1. -- -- see: https://github.com/sol/hpack name: morpheus-graphql-subscriptions-version: 0.28.1+version: 0.28.2 synopsis: Morpheus GraphQL Subscriptions description: Build GraphQL APIs with your favourite functional language! category: web, graphql, subscriptions@@ -42,15 +42,15 @@ build-depends: aeson >=1.4.4 && <3.0.0 , base >=4.7.0 && <5.0.0- , bytestring >=0.10.4 && <0.15.0+ , bytestring >=0.10.4 && <1.0.0 , morpheus-graphql-app >=0.28.0 && <0.29.0 , morpheus-graphql-core >=0.28.0 && <0.29.0 , mtl >=2.0.0 && <3.0.0 , relude >=0.3.0 && <2.0.0 , text >=1.2.3 && <3.0.0- , transformers >=0.3.0 && <0.7.0- , unliftio-core >=0.0.1 && <0.4.0- , unordered-containers >=0.2.8 && <0.3.0- , uuid >=1.0.0 && <1.4.0+ , transformers >=0.3.0 && <1.0.0+ , unliftio-core >=0.0.1 && <1.0.0+ , unordered-containers >=0.2.8 && <1.0.0+ , uuid >=1.0.0 && <2.0.0 , websockets >=0.12.6.0 && <1.0.0 default-language: Haskell2010
src/Data/Morpheus/Subscriptions.hs view
@@ -93,10 +93,10 @@ instance (Show ch, Eq ch, Hashable ch) => PubApp (Event ch con) where runPubApp [] app = runApp app runPubApp callbacks app =- mapAPI $- runStreamHTTP PubContext {eventPublisher = runEvents callbacks}- . streamApp app- . Request+ mapAPI+ $ runStreamHTTP PubContext {eventPublisher = runEvents callbacks}+ . streamApp app+ . Request instance SubApp ServerApp () where runSubApp _ =
src/Data/Morpheus/Subscriptions/Apollo.hs view
@@ -91,9 +91,12 @@ where objectParser o = ApolloSubscription- <$> o .:? "id"- <*> o .: "type"- <*> o .:? "payload"+ <$> o+ .:? "id"+ <*> o+ .: "type"+ <*> o+ .:? "payload" data RequestPayload = RequestPayload { payloadOperationName :: Maybe FieldName,@@ -107,16 +110,20 @@ where objectParser o = RequestPayload- <$> o .:? "operationName"- <*> o .:? "query"- <*> o .:? "variables"+ <$> o+ .:? "operationName"+ <*> o+ .:? "query"+ <*> o+ .:? "variables" instance (ToJSON a) => ToJSON (ApolloSubscription a) where toEncoding (ApolloSubscription id' type' payload') =- pairs $- encodeMaybe "id" id'- <> "type" .= type'- <> encodeMaybe "payload" payload'+ pairs+ $ encodeMaybe "id" id'+ <> "type"+ .= type'+ <> encodeMaybe "payload" payload' where -- Messages should only include these fields when they have real values, -- for example the MessageAck response should only include the type and optionally@@ -131,8 +138,8 @@ PendingConnection -> m Connection acceptApolloRequest pending =- liftIO $- acceptRequestWith+ liftIO+ $ acceptRequestWith pending (acceptApolloSubProtocol (pendingRequest pending)) @@ -219,10 +226,10 @@ validateSub ApolloSubscription {apolloType = GqlComplete, apolloId} = SessionStop <$> validateSession apolloId validateSub ApolloSubscription {apolloType} =- Left $- "Unknown Request type \""- <> pack (unpack $ apolloResponseToProtocolMsgType apolloType)- <> "\"."+ Left+ $ "Unknown Request type \""+ <> pack (unpack $ apolloResponseToProtocolMsgType apolloType)+ <> "\"." validateSession :: Maybe ID -> Validation ID validateSession = maybe (Left "\"id\" was not provided") Right
src/Data/Morpheus/Subscriptions/ClientConnectionStore.hs view
@@ -202,7 +202,7 @@ ClientConnectionStore (Event channel content) m deriving instance- Show e =>+ (Show e) => Show (ClientConnectionStore (Event e c) m) type StoreMap e m =
src/Data/Morpheus/Subscriptions/Internal.hs view
@@ -85,7 +85,7 @@ import Data.UUID.V4 (nextRandom) import Relude hiding (empty, toList) -connect :: MonadIO m => m (Input SUB)+connect :: (MonadIO m) => m (Input SUB) connect = InitConnection <$> liftIO nextRandom disconnect :: ApiContext SUB e m -> Input SUB -> m ()@@ -128,7 +128,7 @@ writeStore = \changes -> liftIO $ modifyMVar_ store (return . changes) } -finallyM :: MonadUnliftIO m => m () -> m () -> m ()+finallyM :: (MonadUnliftIO m) => m () -> m () -> m () finallyM loop end = withRunInIO $ \runIO -> finally (runIO loop) (runIO end) connectionThread ::
src/Data/Morpheus/Subscriptions/Stream.hs view
@@ -158,11 +158,11 @@ handleAction (SessionStart sessionId request) = handleResponseStream (SessionID clientId sessionId) (gqlApp request) handleAction (SessionStop sessionId) =- liftWS $- Right [WSUpdate $ endSession (SessionID clientId sessionId)]+ liftWS+ $ Right [WSUpdate $ endSession (SessionID clientId sessionId)] liftWS ::- Applicative m =>+ (Applicative m) => Either ByteString [WSOutputEvent e m] -> Output SUB e m liftWS = SubOutput . const . pure
src/Data/Morpheus/Subscriptions/WebSockets.hs view
@@ -43,7 +43,7 @@ pingThread connection = (WS.forkPingThread connection 30 >>) #endif -defaultWSScope :: MonadIO m => Store e m -> Connection -> ApiContext SUB e m+defaultWSScope :: (MonadIO m) => Store e m -> Connection -> ApiContext SUB e m defaultWSScope Store {writeStore} connection = SubContext { listener = liftIO (receiveData connection),@@ -57,10 +57,10 @@ (ApiContext SUB e m -> m ()) -> m ServerApp webSocketsWrapper store handler =- withRunInIO $- \runIO ->- pure $- \pending -> do+ withRunInIO+ $ \runIO ->+ pure+ $ \pending -> do conn <- acceptApolloRequest pending pingThread conn