summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2019-09-06 07:48:01 +0200
committerEugen Wissner <belka@caraus.de>2019-09-06 07:48:01 +0200
commit1704022e744b276e0010f5ff147af1f109d30154 (patch)
treeccf62411cdd814ee253b62b9d336438aeb5c4c22
parent63d4de485d3cd96c00480dfe2e5a6cb320d520c7 (diff)
downloadgraphql-1704022e744b276e0010f5ff147af1f109d30154.tar.gz
Fix #12
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/Language/GraphQL/Parser.hs2
-rw-r--r--tests/Language/GraphQL/ParserSpec.hs14
3 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9494208..0ce3323 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,9 @@ All notable changes to this project will be documented in this file.
There are actually only two generic types in GraphQL: Scalars and objects.
Enum is a scalar value.
+### Fixed
+- Parsing block string values.
+
## [0.5.0.0] - 2019-08-14
### Added
- `executeWithName` executes an operation with the given name.
diff --git a/src/Language/GraphQL/Parser.hs b/src/Language/GraphQL/Parser.hs
index 17482d7..5ae71b2 100644
--- a/src/Language/GraphQL/Parser.hs
+++ b/src/Language/GraphQL/Parser.hs
@@ -108,8 +108,8 @@ value = ValueVariable <$> variable
<|> ValueInt <$> integer
<|> ValueBoolean <$> booleanValue
<|> ValueNull <$ symbol "null"
- <|> ValueString <$> string
<|> ValueString <$> blockString
+ <|> ValueString <$> string
<|> ValueEnum <$> try enumValue
<|> ValueList <$> listValue
<|> ValueObject <$> objectValue
diff --git a/tests/Language/GraphQL/ParserSpec.hs b/tests/Language/GraphQL/ParserSpec.hs
index c412c85..6425ea5 100644
--- a/tests/Language/GraphQL/ParserSpec.hs
+++ b/tests/Language/GraphQL/ParserSpec.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE QuasiQuotes #-}
module Language.GraphQL.ParserSpec
( spec
) where
@@ -11,8 +12,19 @@ import Test.Hspec ( Spec
, shouldSatisfy
)
import Text.Megaparsec (parse)
+import Text.RawString.QQ (r)
spec :: Spec
-spec = describe "Parser" $
+spec = describe "Parser" $ do
it "accepts BOM header" $
parse document "" "\xfeff{foo}" `shouldSatisfy` isRight
+
+ it "accepts block strings as argument" $
+ parse document "" [r|{
+ hello(text: """Argument""")
+ }|] `shouldSatisfy` isRight
+
+ it "accepts strings as argument" $
+ parse document "" [r|{
+ hello(text: "Argument")
+ }|] `shouldSatisfy` isRight