From 98d2d41cda148cd086099f3c2c2bc2ba70d9cfba Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Mon, 15 Feb 2016 14:25:15 +0100 Subject: Initial support for variable substitution The correspondent end-to-end test has been ported. The variable definition still needs to be checked. --- Data/GraphQL/Schema.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Data/GraphQL/Schema.hs') diff --git a/Data/GraphQL/Schema.hs b/Data/GraphQL/Schema.hs index 8ceb11f..8d63696 100644 --- a/Data/GraphQL/Schema.hs +++ b/Data/GraphQL/Schema.hs @@ -4,10 +4,11 @@ module Data.GraphQL.Schema where #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>)) #endif +import Data.String (IsString(fromString)) import Data.Aeson (ToJSON(toJSON)) import Data.HashMap.Strict (HashMap) -import Data.Text (Text) +import Data.Text (Text, pack) data Schema f = Schema (QueryRoot f) -- (Maybe MutationRoot) @@ -25,6 +26,8 @@ data Output = OutputObject (HashMap Text Output) type Argument = (Text, Scalar) +type Subs = Text -> Maybe Scalar + data Input = InputField Text [Argument] [Input] deriving (Show) @@ -36,6 +39,9 @@ data Scalar = ScalarInt Int | ScalarID Text deriving (Show) +instance IsString Scalar where + fromString = ScalarString . pack + instance ToJSON Scalar where toJSON (ScalarInt x) = toJSON x toJSON (ScalarFloat x) = toJSON x -- cgit v1.2.3