GraphQLSwift / GraphQL

The Swift GraphQL implementation for macOS and Linux
MIT License
938 stars 72 forks source link

GraphQL parser does not support optional `Description`s. #63

Closed haikusw closed 4 years ago

haikusw commented 4 years ago

Simple test - uncomment out either comment line to watch it fail with a syntax error.

    func testParseDescription() throws {
        let sourceText = """
            # "Foo description text"
            type Foo {
              # "foo field description text"
              fooType: Int
            }
            """

        let doc = try parse(instrumentation: NoOpInstrumentation, source: Source(body: sourceText))
        for def in doc.definitions {
            print( def.kind )
        }
    }

For this first one (object StypeSystemDefinition" the error appears to be on line 158 where it expects (requires) to find the name instead of checking for the optional description string.

Presumably the others are similar.

The list of nodes that can have a description according to the GraphQL Spec (working draft) seems to be:

via parseTypeSystemDefinition:

others:

I have a PR adding support for this that I'll post shortly.