Skip to content

Unexpected Name "directive" #248

@glebsts

Description

@glebsts

What happened?

I got error while applying http://github.com/Yamashou/gqlgenc to my schemas.
I discovered similar issue at that repo first (gqlgo/gqlgenc#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

  • go list -m github.com/vektah/gqlparser/v2?
    took latest master aed070fd commit.
    github.com/vektah/gqlparser/v2
  • go version?
    go version go1.19.3 windows/amd64

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions