jcward / haxe-graphql

Utilities for working with Haxe and GraphQL.
MIT License
23 stars 6 forks source link

OperationDefinitionNode contains NamedTypeNode instead of NameNode #14

Closed Randonee closed 6 years ago

Randonee commented 6 years ago

Using this as input:

query AQuery {
  title
  id
  course_id
  content {
    id
  }
  unlock_at
  submissions {
    id
  }
}

The OperationDefinitionNode in the returned AST will be:

{
    directives:[]
    kind: "OperationDefinition"
    loc:{start: 5, end: 5, source: "Untitled", startToken: null, endToken: null}
    name:{
        kind: "NamedType"
        loc: {start: 6, end: 12, source: "Untitled", startToken: null, endToken: null}
        value: "AQuery"
    }
    ...
}

It should be:

{
    directives:[]
    kind: "OperationDefinition"
    loc:{start: 5, end: 5, source: "Untitled", startToken: null, endToken: null}
    name:{
        kind: "Name"
        value: "AQuery"
    }
    ...
}

I'm using this as reference: https://github.com/graphql/graphql-js/blob/master/src/language/ast.js

Randonee commented 6 years ago

ArgumentNode has the same issue

jcward commented 6 years ago

Fixed by translating parser from graphql-js.

You can verify quickly in the web demo: http://jcward.com/gql2hx/ (note proper kind:"Name")

selection_999 2444