-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Morpheus GraphQL Subscriptions
--
-- Build GraphQL APIs with your favourite functional language!
@package morpheus-graphql-subscriptions
@version 0.19.2
module Data.Morpheus.Subscriptions.Internal
connect :: MonadIO m => m (Input SUB)
disconnect :: ApiContext SUB e m -> Input SUB -> m ()
connectionThread :: (MonadUnliftIO m, Eq ch, Hashable ch) => App (Event ch con) m -> ApiContext SUB (Event ch con) m -> m ()
runStreamWS :: Monad m => ApiContext SUB e m -> Output SUB e m -> m ()
runStreamHTTP :: Monad m => ApiContext PUB e m -> Output PUB e m -> m GQLResponse
data ApiContext (api :: API) event (m :: Type -> Type)
[PubContext] :: {eventPublisher :: event -> m ()} -> ApiContext PUB event m
[SubContext] :: {listener :: m ByteString, callback :: ByteString -> m (), updateStore :: (ClientConnectionStore event m -> ClientConnectionStore event m) -> m ()} -> ApiContext SUB event m
data Input (api :: API)
[InitConnection] :: UUID -> Input SUB
[Request] :: GQLRequest -> Input PUB
type PUB = 'PUB
type SUB = 'SUB
-- | PubSubStore interface shared GraphQL state between websocket
-- and http server, you can define your own store if you provide
-- write and read methods to work properly Morpheus needs all entries of
-- ClientConnectionStore (+ client Callbacks) that why it is recommended
-- that you use many local ClientStores on every server node rather then
-- single centralized Store.
data Store e m
Store :: m (ClientConnectionStore e m) -> ((ClientConnectionStore e m -> ClientConnectionStore e m) -> m ()) -> Store e m
[readStore] :: Store e m -> m (ClientConnectionStore e m)
[writeStore] :: Store e m -> (ClientConnectionStore e m -> ClientConnectionStore e m) -> m ()
data ClientConnectionStore e (m :: Type -> Type)
acceptApolloRequest :: MonadIO m => PendingConnection -> m Connection
data SessionID
publish :: (Monad m, Eq channel, Hashable channel, Show channel) => Event channel content -> ClientConnectionStore (Event channel content) m -> m ()
-- | initializes empty GraphQL state
initDefaultStore :: (MonadIO m, MonadIO m2) => m2 (Store (Event ch con) m)
publishEventWith :: (MonadIO m, Eq channel, Hashable channel, Show channel) => Store (Event channel cont) m -> Event channel cont -> m ()
empty :: Empty coll => coll
toList :: ClientConnectionStore (Event channel content) m -> [(UUID, ClientConnection m)]
connectionSessionIds :: ClientConnection m -> [Text]
storedSessions :: ClientConnectionStore (Event channel content) m -> [(SessionID, ClientSession (Event channel content) m)]
storedChannels :: ClientConnectionStore (Event channel content) m -> [(channel, [SessionID])]
streamApp :: (Eq ch, Monad m, Hashable ch) => App (Event ch con) m -> Input api -> Output api (Event ch con) m
-- | GraphQL Wai Server Applications
module Data.Morpheus.Subscriptions
-- | Wai WebSocket Server App for GraphQL subscriptions
webSocketsApp :: (MonadUnliftIO m, MonadIO m, SubApp ServerApp e) => App e m -> m (ServerApp, e -> m ())
httpPubApp :: (PubApp e, MapAPI a b, MonadIO m) => [e -> m ()] -> App e m -> a -> m b
class PubApp e
runPubApp :: (PubApp e, MonadIO m, MapAPI a b) => [e -> m ()] -> App e m -> a -> m b
class SubApp app e
runSubApp :: (SubApp app e, MonadIO m, MonadUnliftIO m) => App e m -> m (app, e -> m ())
data Event ch con
Event :: [ch] -> con -> Event ch con
[channels] :: Event ch con -> [ch]
[content] :: Event ch con -> con
-- | WebSockets application that can be ran by a server. Once this
-- IO action finishes, the underlying socket is closed
-- automatically.
type ServerApp = PendingConnection -> IO ()
-- | The class of types that can be converted to a hash value.
--
-- Minimal implementation: hashWithSalt.
--
-- Note: the hash is not guaranteed to be stable across library
-- versions, operating systems or architectures. For stable hashing use
-- named hashes: SHA256, CRC32 etc.
--
-- If you are looking for Hashable instance in time
-- package, check time-compat
class Hashable a
instance (GHC.Show.Show ch, GHC.Classes.Eq ch, Data.Hashable.Class.Hashable ch) => Data.Morpheus.Subscriptions.PubApp (Data.Morpheus.Subscriptions.Event.Event ch con)
instance Data.Morpheus.Subscriptions.PubApp ()
instance (GHC.Show.Show ch, GHC.Classes.Eq ch, Data.Hashable.Class.Hashable ch) => Data.Morpheus.Subscriptions.SubApp Network.WebSockets.Server.ServerApp (Data.Morpheus.Subscriptions.Event.Event ch con)
instance Data.Morpheus.Subscriptions.SubApp Network.WebSockets.Server.ServerApp ()