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