summaryrefslogtreecommitdiff
path: root/Data/GraphQL/Printer.hs
diff options
context:
space:
mode:
authorDanny Navarro <j@dannynavarro.net>2015-09-22 13:53:37 +0200
committerDanny Navarro <j@dannynavarro.net>2015-09-22 14:02:49 +0200
commit06b3302862e0c427439136241fb6299f215cec52 (patch)
tree338b9ecc208b4b25dfeaab61d2d326e6020aa3a8 /Data/GraphQL/Printer.hs
parent45083642667fce8a1f6d1491f3487243416e8cc0 (diff)
downloadgraphql-06b3302862e0c427439136241fb6299f215cec52.tar.gz
Add kitchen sink parse/encode unit test
This also includes the fixes to make it work. Golden tests have been removed.
Diffstat (limited to 'Data/GraphQL/Printer.hs')
-rw-r--r--Data/GraphQL/Printer.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/Data/GraphQL/Printer.hs b/Data/GraphQL/Printer.hs
index 4a4d67e..f241220 100644
--- a/Data/GraphQL/Printer.hs
+++ b/Data/GraphQL/Printer.hs
@@ -10,8 +10,9 @@ import Data.GraphQL.AST
-- * Document
+-- TODO: Use query shorthand
document :: Document -> Text
-document (Document defs) = mconcat $ definition <$> defs
+document (Document defs) = (`snoc` '\n') . mconcat $ definition <$> defs
definition :: Definition -> Text
definition (DefinitionOperation x) = operationDefinition x
@@ -102,7 +103,7 @@ booleanValue False = "false"
-- TODO: Escape characters
stringValue :: StringValue -> Text
-stringValue (StringValue x) = x
+stringValue (StringValue v) = quotes v
listValue :: ListValue -> Text
listValue (ListValue vs) = bracketsCommas value vs
@@ -222,6 +223,9 @@ brackets = between '[' ']'
braces :: Text -> Text
braces = between '{' '}'
+quotes :: Text -> Text
+quotes = between '"' '"'
+
spaces :: (a -> Text) -> [a] -> Text
spaces f = intercalate "\SP" . fmap f