2020-11-12 12:25:48 +03:00
|
|
|
-- | Classes for monads used during schema construction and query parsing.
|
|
|
|
module Hasura.GraphQL.Parser.Class.Parse where
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Parser.JSONPath
|
|
|
|
import Hasura.Base.Error
|
|
|
|
import Hasura.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
|
|
|
|
withPath :: (JSONPath -> JSONPath) -> 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
|