From 8e3bae4b5c18dd1647e2a1de5c51802531b90ddb Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sat, 17 Oct 2015 13:19:00 +0200 Subject: Initial stub for a `GraphQL` and `execute` --- Data/GraphQL/Execute.hs | 14 ++++++++++++++ Data/GraphQL/Schema.hs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Data/GraphQL/Execute.hs create mode 100644 Data/GraphQL/Schema.hs (limited to 'Data') diff --git a/Data/GraphQL/Execute.hs b/Data/GraphQL/Execute.hs new file mode 100644 index 0000000..9951144 --- /dev/null +++ b/Data/GraphQL/Execute.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE CPP #-} +module Data.GraphQL.Execute where + +#if !MIN_VERSION_base(4,8,0) +import Control.Applicative (Applicative) +#endif + +import qualified Data.Aeson as Aeson (Value) + +import Data.GraphQL.AST +import Data.GraphQL.Schema + +execute :: Applicative f => Schema -> Document -> f Aeson.Value +execute = undefined diff --git a/Data/GraphQL/Schema.hs b/Data/GraphQL/Schema.hs new file mode 100644 index 0000000..cfa1c9c --- /dev/null +++ b/Data/GraphQL/Schema.hs @@ -0,0 +1,51 @@ +module Data.GraphQL.Schema where + +import Data.Text (Text) +import Data.HashMap.Lazy (HashMap) + +data Schema = Schema QueryRoot MutationRoot + +type QueryRoot = ObjectOutput + +type MutationRoot = ObjectOutput + +type ObjectOutput = HashMap Text Output + +type ObjectInput = HashMap Text Input + +data Type = TypeScalar Scalar + | TypeOutputObject ObjectOutput + | TypeInterface Interface + | TypeUnion Union + | TypeEnum Scalar + | TypeInputObject ObjectInput + | TypeList List + | TypeNonNull NonNull + +data Output = OutputScalar Scalar + | OutputObject ObjectOutput + | OutputInterface Interface + | OutputUnion Union + | OutputEnum Scalar + | OutputList List + | OutputNonNull NonNull + +data Input = InputScalar Scalar + | InputObject ObjectInput + | InputEnum Scalar + | InputList List + | InputNonNull NonNull + +data Scalar = ScalarInt Int + | ScalarFloat Double + | ScalarString Text + | ScalarBool Bool + | ScalarID Text + +newtype Interface = Interface (HashMap Text Output) + +newtype Union = Union [ObjectOutput] + +type List = [Type] + +type NonNull = Type -- cgit v1.2.3