Fix value
parsing
- Add missing variable parsing. - Reuse `name` in value string. This parses successfully the `kitchen-sink.graphql` sample from `graphql-js`.
This commit is contained in:
parent
c0b6fc8a05
commit
26e2372c5e
@ -149,12 +149,13 @@ typeCondition = namedType
|
|||||||
-- This will try to pick the first type it can parse. If you are working with
|
-- This will try to pick the first type it can parse. If you are working with
|
||||||
-- explicit types use the `typedValue` parser.
|
-- explicit types use the `typedValue` parser.
|
||||||
value :: Parser Value
|
value :: Parser Value
|
||||||
value = -- TODO: Handle arbitrary precision.
|
value = ValueVariable <$> variable
|
||||||
ValueInt <$> signed decimal
|
-- TODO: Handle arbitrary precision.
|
||||||
<|> ValueFloat <$> signed double
|
<|> ValueInt <$> tok (signed decimal)
|
||||||
|
<|> ValueFloat <$> tok (signed double)
|
||||||
<|> ValueBoolean <$> bool
|
<|> ValueBoolean <$> bool
|
||||||
-- TODO: Handle escape characters, unicode, etc
|
-- TODO: Handle escape characters, unicode, etc
|
||||||
<|> ValueString <$ "\"" <*> (pack <$> many anyChar) <* "\""
|
<|> ValueString <$> quotes name
|
||||||
-- `true` and `false` have been tried before
|
-- `true` and `false` have been tried before
|
||||||
<|> ValueEnum <$> name
|
<|> ValueEnum <$> name
|
||||||
<|> ValueList <$> listValue
|
<|> ValueList <$> listValue
|
||||||
@ -172,8 +173,8 @@ objectField :: Parser ObjectField
|
|||||||
objectField = ObjectField <$> name <* tok ":" <*> value
|
objectField = ObjectField <$> name <* tok ":" <*> value
|
||||||
|
|
||||||
bool :: Parser Bool
|
bool :: Parser Bool
|
||||||
bool = True <$ "true"
|
bool = True <$ tok "true"
|
||||||
<|> False <$ "false"
|
<|> False <$ tok "false"
|
||||||
|
|
||||||
-- * Directives
|
-- * Directives
|
||||||
|
|
||||||
@ -305,6 +306,9 @@ parens = between "(" ")"
|
|||||||
braces :: Parser a -> Parser a
|
braces :: Parser a -> Parser a
|
||||||
braces = between "{" "}"
|
braces = between "{" "}"
|
||||||
|
|
||||||
|
quotes :: Parser a -> Parser a
|
||||||
|
quotes = between "\"" "\""
|
||||||
|
|
||||||
brackets :: Parser a -> Parser a
|
brackets :: Parser a -> Parser a
|
||||||
brackets = between "[" "]"
|
brackets = between "[" "]"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user