YouTag icon indicating copy to clipboard operation
YouTag copied to clipboard

GraphQL parser does not seem to have support for the '&' character

Open haikusw opened this issue 4 years ago • 2 comments

This is discussed in the graphql specification here.

I noticed when using the GitHub API to test the changes I made for blockstring and descriptions. This API uses these quite a bit. Here's a little test I wrote to show the issue:

import XCTest
import GraphQL

final class graphQLTests: XCTestCase {
  func testParseAmpersand() throws {
    let source = #"""
    """
    Represents a Git blob.
    """
    type Blob implements Node & GitObject {
      """
      An abbreviated version of the Git object ID
      """
      abbreviatedOid: String!

      """
      Byte size of Blob object
      """
      byteSize: Int!

      # other fields omitted
    }
    """#
    let doc = try parse(instrumentation: NoOpInstrumentation, source: Source(body: source))
    for def in doc.definitions {
    print( def.kind )
    }
  }
}

Outputs the error:

/Users/.../graphqltoolTests.swift:46: error: -[testParseAmpersand] : failed: caught error: "Syntax Error GraphQL (4:27) Unexpected character &.

 3: """
 4: type Blob implements Node & GitObject {
                              ^
 5:   """
"

I will likely try to add support for this, but I don't think I'll have time this week.

haikusw avatar Aug 26 '20 07:08 haikusw

Yes, there are a lot of features that were added to the spec that we didn't implement yet. For example, allowing interfaces to inherit from other interfaces is also something that we need to update. Like I said in a previous comment, most of the work for any new feature supported upstream can be "sourced" directly from the canonical implementation. 🙂

paulofaria avatar Aug 26 '20 11:08 paulofaria

Fixed in this PR

nicholaslythall avatar Nov 05 '20 03:11 nicholaslythall