summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Navarro <j@dannynavarro.net>2017-01-26 19:52:07 -0300
committerDanny Navarro <j@dannynavarro.net>2017-01-26 12:52:07 -0300
commit3e991adf4eaeac4da4d074992a507d651b81733f (patch)
tree537c49892952888795e1c75741924ddbadc2d733
parent10fdf05aa72e89d3109ed97ec3f78b15886677ef (diff)
downloadgraphql-3e991adf4eaeac4da4d074992a507d651b81733f.tar.gz
Add Graphql Core AST
-rw-r--r--Data/GraphQL/AST/Core.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Data/GraphQL/AST/Core.hs b/Data/GraphQL/AST/Core.hs
new file mode 100644
index 0000000..2ca3928
--- /dev/null
+++ b/Data/GraphQL/AST/Core.hs
@@ -0,0 +1,31 @@
+-- | This is the AST meant to be executed.
+module Data.GraphQL.AST.Core where
+
+import Data.Int (Int32)
+import Data.List.NonEmpty (NonEmpty)
+
+import Data.Text (Text)
+
+newtype Name = Name Text deriving (Eq,Show)
+
+newtype Document = Document (NonEmpty Operation) deriving (Eq,Show)
+
+data Operation = Query (NonEmpty Field)
+ | Mutation (NonEmpty Field)
+ deriving (Eq,Show)
+
+data Field = Field Name [Argument] [Field] deriving (Eq,Show)
+
+data Argument = Argument Name Value deriving (Eq,Show)
+
+data Value = ValueInt Int32
+ -- GraphQL Float is double precision
+ | ValueFloat Double
+ | ValueBoolean Bool
+ | ValueString Text
+ | ValueEnum Name
+ | ValueList [Value]
+ | ValueObject [ObjectField]
+ deriving (Eq,Show)
+
+data ObjectField = ObjectField Name Value deriving (Eq,Show)