diff options
| author | Danny Navarro <j@dannynavarro.net> | 2015-09-14 14:11:32 +0200 |
|---|---|---|
| committer | Danny Navarro <j@dannynavarro.net> | 2015-09-14 14:14:25 +0200 |
| commit | 26e2372c5eff44f2f28b030b7fca4823be9fe64e (patch) | |
| tree | 5ed557136c429c41098fd64d710db28bcea305de /Data | |
| parent | c0b6fc8a05bb36e37bffd392a9a1883782ac5143 (diff) | |
| download | graphql-26e2372c5eff44f2f28b030b7fca4823be9fe64e.tar.gz | |
Fix `value` parsing
- Add missing variable parsing.
- Reuse `name` in value string.
This parses successfully the `kitchen-sink.graphql` sample from
`graphql-js`.
Diffstat (limited to 'Data')
| -rw-r--r-- | Data/GraphQL/Parser.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Data/GraphQL/Parser.hs b/Data/GraphQL/Parser.hs index 9e3c562..1cd5cb6 100644 --- a/Data/GraphQL/Parser.hs +++ b/Data/GraphQL/Parser.hs @@ -149,12 +149,13 @@ typeCondition = namedType -- This will try to pick the first type it can parse. If you are working with -- explicit types use the `typedValue` parser. value :: Parser Value -value = -- TODO: Handle arbitrary precision. - ValueInt <$> signed decimal - <|> ValueFloat <$> signed double +value = ValueVariable <$> variable + -- TODO: Handle arbitrary precision. + <|> ValueInt <$> tok (signed decimal) + <|> ValueFloat <$> tok (signed double) <|> ValueBoolean <$> bool -- TODO: Handle escape characters, unicode, etc - <|> ValueString <$ "\"" <*> (pack <$> many anyChar) <* "\"" + <|> ValueString <$> quotes name -- `true` and `false` have been tried before <|> ValueEnum <$> name <|> ValueList <$> listValue @@ -172,8 +173,8 @@ objectField :: Parser ObjectField objectField = ObjectField <$> name <* tok ":" <*> value bool :: Parser Bool -bool = True <$ "true" - <|> False <$ "false" +bool = True <$ tok "true" + <|> False <$ tok "false" -- * Directives @@ -305,6 +306,9 @@ parens = between "(" ")" braces :: Parser a -> Parser a braces = between "{" "}" +quotes :: Parser a -> Parser a +quotes = between "\"" "\"" + brackets :: Parser a -> Parser a brackets = between "[" "]" |
