diff options
| author | Eugen Wissner <belka@caraus.de> | 2021-05-10 09:43:39 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2021-05-10 09:43:39 +0200 |
| commit | 1af95345d21ecfaa0823cc5343d2ccc83c89d449 (patch) | |
| tree | 1fc442bf20d116254a39c4ab17659d9e88dcfe68 /src/Language/GraphQL/Execute/Internal.hs | |
| parent | 0d23df3da29cfe0b78af922cea71db5fa1d5c98c (diff) | |
| download | graphql-1af95345d21ecfaa0823cc5343d2ccc83c89d449.tar.gz | |
Deprecate internal error generation functions
The functions generating errors in the executor should be changed anyway
when we provide better error messages from the executor, with the error
location and response path. So public definitions of these functions are
deprecated now and they are replaced by more generic functions in the
executor code.
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 [] [] |
