forked from OSS/graphql
Initial support for variable substitution
The correspondent end-to-end test has been ported. The variable definition still needs to be checked.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user