aerogear / graphback

Graphback - Out of the box GraphQL server and client
https://graphback.dev
Apache License 2.0
409 stars 73 forks source link

buildGraphbackAPI errors with custom directives #2301

Open alexrhogue opened 3 years ago

alexrhogue commented 3 years ago

Hey all. We started talking about this issue over on discord: https://discord.com/channels/632220458137419776/632220563540017153/879799832452161587

I attempted to add and use a custom directive in my data modal schema as part of a query:

directive @withCustom on FIELD_DEFINITION 

type Response {
  custom: String @withCustom
}

type Query {
  getCustom: Response
}

The schema and graphback code were generated correctly. But at runtime buildGraphbackAPI is throwing the following error:

app    | /usr/src/app/node_modules/graphql/error/syntaxError.js:15
app    |   return new _GraphQLError.GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
app    |          ^
app    | GraphQLError: Syntax Error: Expected Name, found Int "0".
app    |     at syntaxError (/usr/src/app/node_modules/graphql/error/syntaxError.js:15:10)
app    |     at Parser.expectToken (/usr/src/app/node_modules/graphql/language/parser.js:1423:40)
app    |     at Parser.parseName (/usr/src/app/node_modules/graphql/language/parser.js:92:22)
app    |     at Parser.parseDirective (/usr/src/app/node_modules/graphql/language/parser.js:619:18)
app    |     at Parser.parseDirectives (/usr/src/app/node_modules/graphql/language/parser.js:604:28)
app    |     at Parser.parseFieldDefinition (/usr/src/app/node_modules/graphql/language/parser.js:873:27)
app    |     at Parser.optionalMany (/usr/src/app/node_modules/graphql/language/parser.js:1516:28)
app    |     at Parser.parseFieldsDefinition (/usr/src/app/node_modules/graphql/language/parser.js:858:17)
app    |     at Parser.parseObjectTypeDefinition (/usr/src/app/node_modules/graphql/language/parser.js:806:23)
app    |     at Parser.parseTypeSystemDefinition (/usr/src/app/node_modules/graphql/language/parser.js:702:23)

I'm using:

Any help or advice would be appreciated. Thanks!

alexrhogue commented 3 years ago

Simple example repo: https://github.com/alexrhogue/directive-detective