encode null value as "null"

This commit is contained in:
Dmitrii Skurikhin 2020-03-31 10:04:34 +03:00
parent 613e929d91
commit 30d6a0a58d
3 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,9 @@ and this project adheres to
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
## [Unreleased]
### Fixed
- Result of null encoding
### Added
- AST for the GraphQL schema.
- Type system definition parser.

View File

@ -205,7 +205,7 @@ value _ (Full.Variable x) = variable x
value _ (Full.Int x) = Builder.toLazyText $ decimal x
value _ (Full.Float x) = Builder.toLazyText $ realFloat x
value _ (Full.Boolean x) = booleanValue x
value _ Full.Null = mempty
value _ Full.Null = "null"
value formatter (Full.String string) = stringValue formatter string
value _ (Full.Enum x) = Lazy.Text.fromStrict x
value formatter (Full.List x) = listValue formatter x

View File

@ -12,6 +12,11 @@ import Text.RawString.QQ (r)
spec :: Spec
spec = do
describe "value" $ do
context "null value" $ do
let testNull formatter = value formatter Null `shouldBe` "null"
it "minified" $ testNull minified
it "pretty" $ testNull pretty
context "minified" $ do
it "escapes \\" $
value minified (String "\\") `shouldBe` "\"\\\\\""