graphql-engine/server/src-lib/Hasura/GraphQL/Parser/Class/Parse.hs
Samir Talwar 975b022b29 server/parsers: Reduce usages of "utils"-like functions.
This reduces the usage of "utils" modules in the parsers code, especially those that are simply re-exported from elsewhere, to facilitate extracting the parsers code into its own library.

It mostly inlines the imports that are re-exported from `Hasura.Prelude` and `Data.Parser.JSONPath`. It also removes references to `Data.*.Extended` modules. When necessary, it re-implements the functionality (which is typically trivial).

It does not tackle all external dependencies. I observed the following that will take more work:

- `Data.GADT.Compare.Extended`
- `Data.Text.Extended`
- `Hasura.Base.Error`
- `Hasura.RQL.Types.Common`
- `Hasura.Server.Utils`

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4964
GitOrigin-RevId: 54ad3c1b7a31f13e34340ebe9fcc36d0ad57b8bd
2022-07-06 07:56:35 +00:00

24 lines
681 B
Haskell

-- | Classes for monads used during schema construction and query parsing.
module Hasura.GraphQL.Parser.Class.Parse
( MonadParse (..),
parseError,
)
where
import Data.Aeson.Types (JSONPathElement)
import Data.Text (Text)
import Hasura.Base.Error
import Prelude
-- | A class that provides functionality for parsing GraphQL queries, i.e.
-- running a fully-constructed 'Parser'.
class Monad m => MonadParse m where
withKey :: JSONPathElement -> m a -> m a
-- | 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