Graphql-js: parser: Improve error message for description followed by extension definition

Created on 23 Jan 2020  路  4Comments  路  Source: graphql/graphql-js

I've been trying to setup Federation but extend doesn't seem to be parsed by the GraphQL parser.

This is the definition that's throwing the error:

  extend type CurrentIdentity @key(fields: "id") {
    id: ID! @external

    profile: Person
  }

For the full definition check here.

This is the exact error I'm getting:

GraphQLError: Syntax Error: Unexpected Name "extend"
    at syntaxError (/ahau/@ssb-graphql/profile/node_modules/graphql/error/syntaxError.js:15:10)
    at Parser.unexpected (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:1463:41)
    at Parser.parseTypeSystemDefinition (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:715:16)
    at Parser.parseDefinition (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:154:19)
    at Parser.many (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:1518:26)
    at Parser.parseDocument (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:111:25)
    at parse (/ahau/@ssb-graphql/profile/node_modules/graphql/language/parser.js:36:17)
    at parseDocument (/ahau/@ssb-graphql/profile/node_modules/graphql-tag/lib/graphql-tag.umd.js:135:16)
    at gql (/ahau/@ssb-graphql/profile/node_modules/graphql-tag/lib/graphql-tag.umd.js:176:10)
    at Object.<anonymous> (/ahau/@ssb-graphql/profile/src/typeDefs.js:3:21)

And these are the package versions I'm using:

    "@apollo/federation": "^0.11.3",
    "apollo-server": "^2.9.3",
    "apollo-server-express": "^2.9.6",
    "graphql": "^14.5.8",

@IvanGoncharov you might hold the answer.

enhancement

Most helpful comment

@luandro It looks like you have either docstring or comment before extend, right?
It's not allowed to add descriptions to extend definitions but I totally agree that we need to improve error message.

All 4 comments

@luandro It looks like you have either docstring or comment before extend, right?
It's not allowed to add descriptions to extend definitions but I totally agree that we need to improve error message.

OH! Can't believe it was that simple. Been blocker for the whole week :cry:

Thanks @IvanGoncharov!

@luandro Great to hear 馃憤
BTW. If you ever experience a similar issue you can try to catch the error and call console.log(error.toString()) see here for more details: https://github.com/graphql/graphql-js/issues/2215#issuecomment-540054812

@IvanGoncharov I want to work on this. Please assign it to me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthewgertner picture matthewgertner  路  4Comments

benjie picture benjie  路  4Comments

adriano-di-giovanni picture adriano-di-giovanni  路  3Comments

scf4 picture scf4  路  3Comments

rafgraph picture rafgraph  路  4Comments