Skip to content

Issue with parsing non-nullable types #221

Description

@fredefox

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions