vektah / gqlparser

A port of the parser from graphql-js into golang
MIT License
498 stars 123 forks source link

Unexpected Name "directive" #248

Open glebsts opened 1 year ago

glebsts commented 1 year ago

What happened?

I got error while applying http://github.com/Yamashou/gqlgenc to my schemas. I discovered similar issue at that repo first (https://github.com/Yamashou/gqlgenc/issues/88) but traced error back to this parser. I debugged code generation and found that my query and schema values in plugin config referenced same directory, and in this folder there is a directive file (it is first file in the directory, so it failed pretty fast), containing directive @access(num: Int) on FIELD_DEFINITION I use gqlgen for generating my models, and it handles such structure nicely. However, query doc parser here is unable to handle directive token.

What did you expect?

I expect query parser not to fail, and parser to parse my directive correctly. I might be wrong putting schema and query under same folder, but it worked for me with gqlgen server generation, and now I decided to start generating client as well. ❓ So, is it a hard requirement to keep directives out of query folder? ❓ Looks like you can only put query, mutation, subscription and fragment there.

Minimal graphql.schema and models to reproduce

put following into file in under query folder: directive @access(num: Int) on FIELD_DEFINITION and run query parser on that document.

versions

Thank you