Remove StringValue
type
This commit is contained in:
parent
770df82718
commit
d8a731fe30
@ -68,14 +68,12 @@ data Value = ValueVariable Variable
|
|||||||
-- GraphQL Float is double precison
|
-- GraphQL Float is double precison
|
||||||
| ValueFloat Double
|
| ValueFloat Double
|
||||||
| ValueBoolean Bool
|
| ValueBoolean Bool
|
||||||
| ValueString StringValue
|
| ValueString Text
|
||||||
| ValueEnum Name
|
| ValueEnum Name
|
||||||
| ValueList ListValue
|
| ValueList ListValue
|
||||||
| ValueObject ObjectValue
|
| ValueObject ObjectValue
|
||||||
deriving (Eq,Show)
|
deriving (Eq,Show)
|
||||||
|
|
||||||
newtype StringValue = StringValue Text deriving (Eq,Show)
|
|
||||||
|
|
||||||
newtype ListValue = ListValue [Value] deriving (Eq,Show)
|
newtype ListValue = ListValue [Value] deriving (Eq,Show)
|
||||||
|
|
||||||
newtype ObjectValue = ObjectValue [ObjectField] deriving (Eq,Show)
|
newtype ObjectValue = ObjectValue [ObjectField] deriving (Eq,Show)
|
||||||
|
@ -106,8 +106,8 @@ booleanValue True = "true"
|
|||||||
booleanValue False = "false"
|
booleanValue False = "false"
|
||||||
|
|
||||||
-- TODO: Escape characters
|
-- TODO: Escape characters
|
||||||
stringValue :: StringValue -> Text
|
stringValue :: Text -> Text
|
||||||
stringValue (StringValue v) = quotes v
|
stringValue = quotes
|
||||||
|
|
||||||
listValue :: ListValue -> Text
|
listValue :: ListValue -> Text
|
||||||
listValue (ListValue vs) = bracketsCommas value vs
|
listValue (ListValue vs) = bracketsCommas value vs
|
||||||
|
@ -37,5 +37,5 @@ substitute _ sel = sel
|
|||||||
-- TODO: Support different value types
|
-- TODO: Support different value types
|
||||||
subsArg :: Schema.Subs -> Argument -> Maybe Argument
|
subsArg :: Schema.Subs -> Argument -> Maybe Argument
|
||||||
subsArg subs (Argument n (ValueVariable (Variable v))) =
|
subsArg subs (Argument n (ValueVariable (Variable v))) =
|
||||||
Argument n . ValueString . StringValue <$> subs v
|
Argument n . ValueString <$> subs v
|
||||||
subsArg _ arg = Just arg
|
subsArg _ arg = Just arg
|
||||||
|
@ -169,8 +169,8 @@ booleanValue = True <$ tok "true"
|
|||||||
<|> False <$ tok "false"
|
<|> False <$ tok "false"
|
||||||
|
|
||||||
-- TODO: Escape characters. Look at `jsstring_` in aeson package.
|
-- TODO: Escape characters. Look at `jsstring_` in aeson package.
|
||||||
stringValue :: Parser StringValue
|
stringValue :: Parser Text
|
||||||
stringValue = StringValue <$> quotes (takeWhile (/= '"'))
|
stringValue = quotes (takeWhile (/= '"'))
|
||||||
|
|
||||||
-- Notice it can be empty
|
-- Notice it can be empty
|
||||||
listValue :: Parser ListValue
|
listValue :: Parser ListValue
|
||||||
|
@ -18,7 +18,6 @@ module Data.GraphQL.Schema
|
|||||||
, Field
|
, Field
|
||||||
, Argument(..)
|
, Argument(..)
|
||||||
, Value(..)
|
, Value(..)
|
||||||
, StringValue(..)
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
#if !MIN_VERSION_base(4,8,0)
|
#if !MIN_VERSION_base(4,8,0)
|
||||||
|
@ -28,12 +28,12 @@ hero = Schema.objectA "hero" $ \case
|
|||||||
|
|
||||||
human :: Alternative f => Resolver f
|
human :: Alternative f => Resolver f
|
||||||
human = Schema.objectA "human" $ \case
|
human = Schema.objectA "human" $ \case
|
||||||
[Argument "id" (ValueString (StringValue i))] -> character =<< getHuman i
|
[Argument "id" (ValueString i)] -> character =<< getHuman i
|
||||||
_ -> empty
|
_ -> empty
|
||||||
|
|
||||||
droid :: Alternative f => Resolver f
|
droid :: Alternative f => Resolver f
|
||||||
droid = Schema.objectA "droid" $ \case
|
droid = Schema.objectA "droid" $ \case
|
||||||
[Argument "id" (ValueString (StringValue i))] -> character =<< getDroid i
|
[Argument "id" (ValueString i)] -> character =<< getDroid i
|
||||||
_ -> empty
|
_ -> empty
|
||||||
|
|
||||||
character :: Alternative f => Character -> [Resolver f]
|
character :: Alternative f => Character -> [Resolver f]
|
||||||
|
Loading…
Reference in New Issue
Block a user