graphql-api icon indicating copy to clipboard operation
graphql-api copied to clipboard

Issue with parsing non-nullable types

Open fredefox opened this issue 6 years ago • 0 comments

There is a bug that prevents a document such as

input B {
  b: [B!]!
}

from parsing.

Note the difference between:

λ length <$> parseOnly (many1 inputValueDefinition) "b: [B!]! x: B"
Right 1
λ length <$> parseOnly (many1 inputValueDefinition) "b: [B!] x: B"
Right 2

And similarly for

λ length <$> parseOnly (many1 fieldDefinition) "b: [B!] b: B"
Right 2
λ length <$> parseOnly (many1 fieldDefinition) "b: [B!]! b: B"
Right 1

Related to this I want to ask about the definition of NonNullType. Wouldn't it make more sense to define NonNullType to be:

newtype NonNullType = NonNullType GType

Of course this will permit parsing something like A!!! - but I believe it would simplify some of the code and help fix the bug in the parser. One challenge with that approach, though, is that parsing a type declaration will then require a look-ahead. Does the declaration end with an exclamation mark or not.

fredefox avatar Aug 02 '19 07:08 fredefox