{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
module Data.Morpheus.Execution.Server.Interpreter
( Interpreter(..)
)
where
import Data.Morpheus.Types.Internal.Subscription
( Stream
, Input
, toOutStream
)
import Data.Morpheus.Execution.Server.Resolve
( RootResCon
, coreResolver
, statelessResolver
)
import Data.Morpheus.Types.Internal.Resolving
( GQLRootResolver(..)
)
import Data.Morpheus.Types.IO ( GQLRequest
, GQLResponse
, MapAPI(..)
)
class Interpreter e m a b where
interpreter ::
Monad m
=> (RootResCon m e query mut sub)
=> GQLRootResolver m e query mut sub
-> a
-> b
instance Interpreter e m GQLRequest (m GQLResponse) where
interpreter = statelessResolver
instance Interpreter e m (Input api) (Stream api e m) where
interpreter root = toOutStream (coreResolver root)
instance ( MapAPI a ) =>
Interpreter e m a (m a) where
interpreter root = mapAPI (interpreter root)