summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Error.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-09-05 09:14:57 +0200
committerEugen Wissner <belka@caraus.de>2021-09-05 09:14:57 +0200
commit7b00e8a0abb91e93e3ea6f86814b4f50219e1bc8 (patch)
tree4f04cb57bde749e3703d02c605fa04282db7183e /src/Language/GraphQL/Error.hs
parent7444895a58b4a92c8972cc8a7fda690ee0d3b955 (diff)
downloadgraphql-7b00e8a0abb91e93e3ea6f86814b4f50219e1bc8.tar.gz
Deprecate unused functions from the old executor
Diffstat (limited to 'src/Language/GraphQL/Error.hs')
-rw-r--r--src/Language/GraphQL/Error.hs75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/Language/GraphQL/Error.hs b/src/Language/GraphQL/Error.hs
index 43be778..4e461f0 100644
--- a/src/Language/GraphQL/Error.hs
+++ b/src/Language/GraphQL/Error.hs
@@ -44,12 +44,6 @@ import Text.Megaparsec
, unPos
)
--- | Executor context.
-data Resolution m = Resolution
- { errors :: Seq Error
- , types :: HashMap Name (Schema.Type m)
- }
-
-- | Wraps a parse error into a list of errors.
parseError :: (Applicative f, Serialize a)
=> ParseErrorBundle Text Void
@@ -69,32 +63,6 @@ parseError ParseErrorBundle{..} =
sourcePosition = pstateSourcePos newState
in (result |> errorObject x sourcePosition, newState)
--- | A wrapper to pass error messages around.
-type CollectErrsT m = StateT (Resolution m) m
-
--- | Adds an error to the list of errors.
-{-# DEPRECATED #-}
-addErr :: Monad m => Error -> CollectErrsT m ()
-addErr v = modify appender
- where
- appender :: Monad m => Resolution m -> Resolution m
- appender resolution@Resolution{..} = resolution{ errors = errors |> v }
-
-{-# DEPRECATED #-}
-makeErrorMessage :: Text -> Error
-makeErrorMessage s = Error s [] []
-
--- | Constructs a response object containing only the error with the given
--- message.
-{-# DEPRECATED #-}
-singleError :: Serialize a => Text -> Response a
-singleError message = Response null $ Seq.singleton $ Error message [] []
-
--- | Convenience function for just wrapping an error message.
-{-# DEPRECATED #-}
-addErrMsg :: (Monad m, Serialize a) => Text -> CollectErrsT m a
-addErrMsg errorMessage = (addErr . makeErrorMessage) errorMessage >> pure null
-
-- | If an error can be associated to a particular field in the GraphQL result,
-- it must contain an entry with the key path that details the path of the
-- response field which experienced the error. This allows clients to identify
@@ -133,8 +101,13 @@ instance Show ResolverException where
instance Exception ResolverException
+-- * Deprecated
+
-- | Runs the given query computation, but collects the errors into an error
-- list, which is then sent back with the data.
+--
+-- /runCollectErrs was part of the old executor and isn't used anymore, it will
+-- be deprecated in the future and removed./
runCollectErrs :: (Monad m, Serialize a)
=> HashMap Name (Schema.Type m)
-> CollectErrsT m a
@@ -143,3 +116,41 @@ runCollectErrs types' res = do
(dat, Resolution{..}) <- runStateT res
$ Resolution{ errors = Seq.empty, types = types' }
pure $ Response dat errors
+
+-- | Executor context.
+--
+-- /Resolution was part of the old executor and isn't used anymore, it will be
+-- deprecated in the future and removed./
+data Resolution m = Resolution
+ { errors :: Seq Error
+ , types :: HashMap Name (Schema.Type m)
+ }
+
+-- | A wrapper to pass error messages around.
+--
+-- /CollectErrsT was part of the old executor and isn't used anymore, it will be
+-- deprecated in the future and removed./
+type CollectErrsT m = StateT (Resolution m) m
+
+-- | Adds an error to the list of errors.
+{-# DEPRECATED #-}
+addErr :: Monad m => Error -> CollectErrsT m ()
+addErr v = modify appender
+ where
+ appender :: Monad m => Resolution m -> Resolution m
+ appender resolution@Resolution{..} = resolution{ errors = errors |> v }
+
+{-# DEPRECATED #-}
+makeErrorMessage :: Text -> Error
+makeErrorMessage s = Error s [] []
+
+-- | Constructs a response object containing only the error with the given
+-- message.
+{-# DEPRECATED #-}
+singleError :: Serialize a => Text -> Response a
+singleError message = Response null $ Seq.singleton $ Error message [] []
+
+-- | Convenience function for just wrapping an error message.
+{-# DEPRECATED #-}
+addErrMsg :: (Monad m, Serialize a) => Text -> CollectErrsT m a
+addErrMsg errorMessage = (addErr . makeErrorMessage) errorMessage >> pure null