diff options
Diffstat (limited to 'src/Language/GraphQL/Execute/Internal.hs')
| -rw-r--r-- | src/Language/GraphQL/Execute/Internal.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Language/GraphQL/Execute/Internal.hs b/src/Language/GraphQL/Execute/Internal.hs index 3b75da1..792a758 100644 --- a/src/Language/GraphQL/Execute/Internal.hs +++ b/src/Language/GraphQL/Execute/Internal.hs @@ -3,23 +3,34 @@ obtain one at https://mozilla.org/MPL/2.0/. -} {-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE NamedFieldPuns #-} module Language.GraphQL.Execute.Internal ( addError + , singleError ) where import Control.Monad.Trans.State (modify) import Control.Monad.Catch (MonadCatch) import Data.Sequence ((|>)) -import Language.GraphQL.Error +import Data.Text (Text) import Language.GraphQL.Execute.Coerce +import Language.GraphQL.Error + ( CollectErrsT + , Error(..) + , Resolution(..) + , Response(..) + ) import Prelude hiding (null) -addError :: (Serialize a, MonadCatch m) => Error -> CollectErrsT m a -addError error' = modify appender >> pure null +addError :: MonadCatch m => forall a. a -> Error -> CollectErrsT m a +addError returnValue error' = modify appender >> pure returnValue where appender :: Resolution m -> Resolution m appender resolution@Resolution{ errors } = resolution { errors = errors |> error' } + +singleError :: Serialize b => forall a. Text -> Either a (Response b) +singleError message = Right $ Response null $ pure $ Error message [] [] |
