diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-07-14 19:37:56 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-07-14 19:37:56 +0200 |
| commit | ae2210f6598f166116abebc1163e1523d3bc627c (patch) | |
| tree | 02b18f29d0b025a702366e70405dbcc203092c96 /src/Language/GraphQL/Error.hs | |
| parent | 840e129c4496b4e8145480d2b3c3cb34f505702e (diff) | |
| download | graphql-ae2210f6598f166116abebc1163e1523d3bc627c.tar.gz | |
Support subscriptions
This is experimental support.
The implementation is based on conduit and is boring. There is a new
resolver data constructor that should create a source event stream. The
executor receives the events, pipes them through the normal execution
and puts them into the response stream which is returned to the user.
- Tests are missing.
- The executor should check field value resolver on subscription types.
- The graphql function should probably return (Either
ResponseEventStream Response), but I'm not sure about this. It will
make the usage more complicated if no subscriptions are involved, but
with the current API implementing subscriptions is more
difficult than it should be.
Diffstat (limited to 'src/Language/GraphQL/Error.hs')
| -rw-r--r-- | src/Language/GraphQL/Error.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Language/GraphQL/Error.hs b/src/Language/GraphQL/Error.hs index 3dbc696..474ddc7 100644 --- a/src/Language/GraphQL/Error.hs +++ b/src/Language/GraphQL/Error.hs @@ -9,19 +9,20 @@ module Language.GraphQL.Error , Error(..) , Resolution(..) , Response(..) + , ResponseEventStream , addErr , addErrMsg , runCollectErrs , singleError ) where +import Conduit import Control.Monad.Trans.State (StateT, modify, runStateT) import Data.HashMap.Strict (HashMap) import Data.Sequence (Seq(..), (|>)) import qualified Data.Sequence as Seq import Data.Text (Text) import qualified Data.Text as Text -import Data.Void (Void) import Language.GraphQL.AST (Location(..), Name) import Language.GraphQL.Execute.Coerce import Language.GraphQL.Type.Schema @@ -96,6 +97,11 @@ data Response a = Response , errors :: Seq Error } deriving (Eq, Show) +-- | Each event in the underlying Source Stream triggers execution of the +-- subscription selection set. The results of the execution generate a Response +-- Stream. +type ResponseEventStream m a = ConduitT () (Response a) m () + -- | Runs the given query computation, but collects the errors into an error -- list, which is then sent back with the data. runCollectErrs :: (Monad m, Serialize a) |
