From 5390c4ca1e7e6bcf36dbe5e773c1355dd4b65939 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sat, 28 Jan 2017 14:15:14 -0300 Subject: Split AST in 2 One AST is meant to be a target parser and tries to adhere as much as possible to the spec. The other is a simplified version of that AST meant for execution. Also newtypes have been replaced by type synonyms and NonEmpty lists are being used where it makes sense. --- Data/GraphQL/AST/Core.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Data/GraphQL/AST/Core.hs') diff --git a/Data/GraphQL/AST/Core.hs b/Data/GraphQL/AST/Core.hs index 2ca3928..b5698c6 100644 --- a/Data/GraphQL/AST/Core.hs +++ b/Data/GraphQL/AST/Core.hs @@ -6,15 +6,17 @@ import Data.List.NonEmpty (NonEmpty) import Data.Text (Text) -newtype Name = Name Text deriving (Eq,Show) +type Name = Text -newtype Document = Document (NonEmpty Operation) deriving (Eq,Show) +type Document = NonEmpty Operation -data Operation = Query (NonEmpty Field) +data Operation = Query (NonEmpty Field) | Mutation (NonEmpty Field) deriving (Eq,Show) -data Field = Field Name [Argument] [Field] deriving (Eq,Show) +data Field = Field (Maybe Alias) Name [Argument] [Field] deriving (Eq,Show) + +type Alias = Name data Argument = Argument Name Value deriving (Eq,Show) -- cgit v1.2.3 From 693b7d18dcd48525b10ce297f89b3b33fd020784 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sun, 29 Jan 2017 18:44:03 -0300 Subject: Introduce Tranform module In the Transform module the Full AST will converted to Core AST. This commit also includes a partial implementation of Fragment replacement. --- Data/GraphQL/AST/Core.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Data/GraphQL/AST/Core.hs') diff --git a/Data/GraphQL/AST/Core.hs b/Data/GraphQL/AST/Core.hs index b5698c6..3424d20 100644 --- a/Data/GraphQL/AST/Core.hs +++ b/Data/GraphQL/AST/Core.hs @@ -23,8 +23,9 @@ data Argument = Argument Name Value deriving (Eq,Show) data Value = ValueInt Int32 -- GraphQL Float is double precision | ValueFloat Double - | ValueBoolean Bool | ValueString Text + | ValueBoolean Bool + | ValueNull | ValueEnum Name | ValueList [Value] | ValueObject [ObjectField] -- cgit v1.2.3 From b7a72591fd08df9df678e5e7db3304b5a2e75ae9 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sun, 12 Feb 2017 15:19:13 -0300 Subject: Support variables in AST transformation --- Data/GraphQL/AST/Core.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Data/GraphQL/AST/Core.hs') diff --git a/Data/GraphQL/AST/Core.hs b/Data/GraphQL/AST/Core.hs index 3424d20..f0c617c 100644 --- a/Data/GraphQL/AST/Core.hs +++ b/Data/GraphQL/AST/Core.hs @@ -3,6 +3,7 @@ module Data.GraphQL.AST.Core where import Data.Int (Int32) import Data.List.NonEmpty (NonEmpty) +import Data.String import Data.Text (Text) @@ -31,4 +32,7 @@ data Value = ValueInt Int32 | ValueObject [ObjectField] deriving (Eq,Show) +instance IsString Value where + fromString = ValueString . fromString + data ObjectField = ObjectField Name Value deriving (Eq,Show) -- cgit v1.2.3