From 0d23df3da29cfe0b78af922cea71db5fa1d5c98c Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 9 May 2021 12:34:39 +0200 Subject: Provide an internal function to add errors The old function, addErrMsg, takes only a string with an error description, but more information is required for the execution errors: locations and path. addErrMsg should be deprecated after the switching to the new addError. --- src/Language/GraphQL/Execute/Internal.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Language/GraphQL/Execute/Internal.hs (limited to 'src/Language/GraphQL/Execute/Internal.hs') diff --git a/src/Language/GraphQL/Execute/Internal.hs b/src/Language/GraphQL/Execute/Internal.hs new file mode 100644 index 0000000..3b75da1 --- /dev/null +++ b/src/Language/GraphQL/Execute/Internal.hs @@ -0,0 +1,25 @@ +{- This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can + obtain one at https://mozilla.org/MPL/2.0/. -} + +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE NamedFieldPuns #-} + +module Language.GraphQL.Execute.Internal + ( addError + ) where + +import Control.Monad.Trans.State (modify) +import Control.Monad.Catch (MonadCatch) +import Data.Sequence ((|>)) +import Language.GraphQL.Error +import Language.GraphQL.Execute.Coerce +import Prelude hiding (null) + +addError :: (Serialize a, MonadCatch m) => Error -> CollectErrsT m a +addError error' = modify appender >> pure null + where + appender :: Resolution m -> Resolution m + appender resolution@Resolution{ errors } = resolution + { errors = errors |> error' + } -- cgit v1.2.3