-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mis-parsing GraphQL identifiers when it starts with keywords (fix #20) #21
Changes from 4 commits
0e23843
997062d
e2a5d2f
0e8f1f5
edbb555
ed8bd1f
cb5bc05
950c29f
538d804
e78c9e8
bce1d68
8b9e4e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name of the file should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think we should call it something else. It is not really related to columns, but primitive values of GraphQL. |
||
|
||
-- | Regression tests for issue #20 https://github.com/hasura/graphql-parser-hs/issues/20 | ||
|
||
module PrimitiveColumns (primitiveTests) where | ||
|
||
import Hedgehog | ||
import Protolude | ||
import GHC.Base (fail) | ||
|
||
import Language.GraphQL.Draft.Syntax | ||
import Language.GraphQL.Draft.Parser | ||
|
||
import qualified Language.GraphQL.Draft.Printer.Text as PP.TB | ||
import qualified Language.GraphQL.Draft.Printer as P | ||
|
||
primitiveTests :: IsString s => [(s, Property)] | ||
primitiveTests = | ||
[ ("property [ parse (print nameValue) == nameValue ]", propNullNameValue) | ||
, ("property [ parse (print nameBool) == nameBool ]", propBoolNameValue) | ||
, ("property [ parse (print nameName) == nameName ]", propNullNameName) | ||
] | ||
|
||
propNullNameValue :: Property | ||
propNullNameValue = property $ either (fail . Protolude.show) (ast ===) astRoundTrip | ||
where | ||
astRoundTrip = (runParser value) printed | ||
printed = PP.TB.render P.value ast | ||
ast = VList (ListValueG { unListValue = [ | ||
VEnum (EnumValue{unEnumValue = Name{unName = "nullColumn"}})]}) | ||
|
||
propBoolNameValue :: Property | ||
propBoolNameValue = property $ either (fail . Protolude.show) (ast ===) astRoundTrip | ||
where | ||
astRoundTrip = (runParser value) printed | ||
printed = PP.TB.render P.value ast | ||
ast = VList (ListValueG { unListValue = [ | ||
VEnum (EnumValue{unEnumValue = Name{unName = "trueColumn"}})]}) | ||
|
||
propNullNameName :: Property | ||
propNullNameName = property $ either (fail . Protolude.show) (ast ===) astRoundTrip | ||
where | ||
astRoundTrip = (runParser nameParser) printed | ||
printed = PP.TB.render P.nameP ast | ||
ast = Name "nullColumntwo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the hspec format, I don't think we have to include them like this. Do you think this is necessary?