From 06b3302862e0c427439136241fb6299f215cec52 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Tue, 22 Sep 2015 13:53:37 +0200 Subject: Add kitchen sink parse/encode unit test This also includes the fixes to make it work. Golden tests have been removed. --- Data/GraphQL/Printer.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Data/GraphQL/Printer.hs') 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 -- cgit v1.2.3