Move Transform to Language.GraphQL.Execute

Language.GraphQL.AST.Transform is an internal module. Even though it
works with the AST, it is a part of the execution process, it translates
the original parser tree into a simpler one, so the executor has less
work to do. Language.GraphQL.AST should contain only the parser and be
independent from other packages, so it can be used on its own.
This commit is contained in:
Eugen Wissner 2019-12-07 09:46:00 +01:00
parent 3c1a5c800f
commit 4c0d226030
3 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ dependencies:
library:
source-dirs: src
other-modules:
- Language.GraphQL.AST.Transform
- Language.GraphQL.Execute.Transform
- Language.GraphQL.Execute.Directive
tests:

View File

@ -15,7 +15,7 @@ import Data.Text (Text)
import qualified Data.Text as Text
import qualified Language.GraphQL.AST as AST
import qualified Language.GraphQL.AST.Core as AST.Core
import qualified Language.GraphQL.AST.Transform as Transform
import qualified Language.GraphQL.Execute.Transform as Transform
import Language.GraphQL.Error
import qualified Language.GraphQL.Schema as Schema

View File

@ -4,7 +4,7 @@
-- | After the document is parsed, before getting executed the AST is
-- transformed into a similar, simpler AST. This module is responsible for
-- this transformation.
module Language.GraphQL.AST.Transform
module Language.GraphQL.Execute.Transform
( document
) where
@ -30,6 +30,9 @@ data Replacement = Replacement
type TransformT a = StateT Replacement (ReaderT Schema.Subs Maybe) a
liftJust :: forall a. a -> TransformT a
liftJust = lift . lift . Just
-- | Rewrites the original syntax tree into an intermediate representation used
-- for query execution.
document :: Schema.Subs -> Full.Document -> Maybe Core.Document
@ -179,6 +182,3 @@ value (Full.Object o) =
objectField :: Full.ObjectField -> TransformT (Core.Name, Core.Value)
objectField (Full.ObjectField name value') = (name,) <$> value value'
liftJust :: forall a. a -> TransformT a
liftJust = lift . lift . Just