2020-11-12 12:25:48 +03:00
|
|
|
-- | Classes for monads used during schema construction and query parsing.
|
2021-11-04 19:08:33 +03:00
|
|
|
module Hasura.GraphQL.Parser.Class.Parse
|
|
|
|
( MonadParse (..),
|
|
|
|
parseError,
|
|
|
|
)
|
|
|
|
where
|
2020-11-12 12:25:48 +03:00
|
|
|
|
2022-07-06 10:54:57 +03:00
|
|
|
import Data.Aeson.Types (JSONPathElement)
|
|
|
|
import Data.Text (Text)
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Base.Error
|
2022-07-06 10:54:57 +03:00
|
|
|
import Prelude
|
2020-11-12 12:25:48 +03:00
|
|
|
|
|
|
|
-- | A class that provides functionality for parsing GraphQL queries, i.e.
|
|
|
|
-- running a fully-constructed 'Parser'.
|
|
|
|
class Monad m => MonadParse m where
|
2022-06-28 13:06:55 +03:00
|
|
|
withKey :: JSONPathElement -> m a -> m a
|
2021-09-24 01:56:37 +03:00
|
|
|
|
2020-11-12 12:25:48 +03:00
|
|
|
-- | Not the full power of 'MonadError' because parse errors cannot be
|
|
|
|
-- caught.
|
|
|
|
parseErrorWith :: Code -> Text -> m a
|
|
|
|
|
|
|
|
parseError :: MonadParse m => Text -> m a
|
|
|
|
parseError = parseErrorWith ValidationFailed
|