forked from OSS/graphql
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:
parent
3c1a5c800f
commit
4c0d226030
@ -37,7 +37,7 @@ dependencies:
|
|||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
other-modules:
|
other-modules:
|
||||||
- Language.GraphQL.AST.Transform
|
- Language.GraphQL.Execute.Transform
|
||||||
- Language.GraphQL.Execute.Directive
|
- Language.GraphQL.Execute.Directive
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
|
@ -15,7 +15,7 @@ import Data.Text (Text)
|
|||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Language.GraphQL.AST as AST
|
import qualified Language.GraphQL.AST as AST
|
||||||
import qualified Language.GraphQL.AST.Core as AST.Core
|
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 Language.GraphQL.Error
|
||||||
import qualified Language.GraphQL.Schema as Schema
|
import qualified Language.GraphQL.Schema as Schema
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- | After the document is parsed, before getting executed the AST is
|
-- | After the document is parsed, before getting executed the AST is
|
||||||
-- transformed into a similar, simpler AST. This module is responsible for
|
-- transformed into a similar, simpler AST. This module is responsible for
|
||||||
-- this transformation.
|
-- this transformation.
|
||||||
module Language.GraphQL.AST.Transform
|
module Language.GraphQL.Execute.Transform
|
||||||
( document
|
( document
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -30,6 +30,9 @@ data Replacement = Replacement
|
|||||||
|
|
||||||
type TransformT a = StateT Replacement (ReaderT Schema.Subs Maybe) a
|
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
|
-- | Rewrites the original syntax tree into an intermediate representation used
|
||||||
-- for query execution.
|
-- for query execution.
|
||||||
document :: Schema.Subs -> Full.Document -> Maybe Core.Document
|
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 -> TransformT (Core.Name, Core.Value)
|
||||||
objectField (Full.ObjectField name value') = (name,) <$> value value'
|
objectField (Full.ObjectField name value') = (name,) <$> value value'
|
||||||
|
|
||||||
liftJust :: forall a. a -> TransformT a
|
|
||||||
liftJust = lift . lift . Just
|
|
Loading…
Reference in New Issue
Block a user