Relay: [relay-compiler] Compiler fails to parse .graphql with new comment syntax

Created on 29 Dec 2017  路  8Comments  路  Source: facebook/relay

The relay-compiler is unable to parse the new multi-line comment syntax used by printSchema in the graphql package. It's pretty trivial to switch over to a JSON file (instead of .graphql) but this should probably be fixed anyhow.

Given a schema.graphql file containing this:

# ...

type AreaObject implements Node, Object {
  id: ID!

  """This is the name of the area."""
  name: String

  # ...
}

# ...

the command relay-compiler --src ./src --schema ./data/schema.graphql produces:

ERROR:
Error loading schema. Expected the schema to be a .graphql or a .json
file, describing your GraphQL server's API. Error detail:

GraphQLError: Syntax Error GraphQL request (44:3) Expected Name, found String

43:
44:   """This is the name of the area."""
      ^
45:   name: String

Most helpful comment

You can generate it yourself using something like this:

https://gist.github.com/benjie/446380c4167edfc532a88f2034514049

All 8 comments

I second this issue.

Writing default
ERROR:
Error loading schema. Expected the schema to be a .graphql or a .json
file, describing your GraphQL server's API. Error detail:

GraphQLError: Syntax Error GraphQL request (5:3) Unexpected String

4: 
5:   """All input for the `acceptInvite` mutation."""
     ^
6: input AcceptInviteInput {


A temporary solution besides using JSON is passing commentDescriptions: true to printSchema to revert to the previous functionality.

printSchema(schema, {
  commentDescriptions: true,
});

My schema is being generated by a third-party library. @benjie is that something we can do in postgraphile / graphile-build ?

You can generate it yourself using something like this:

https://gist.github.com/benjie/446380c4167edfc532a88f2034514049

Neat. A bit more complicated than would be ideal, but a solution none the less. Thank you :)

This has been fixed in 1.5.0-rc.1, which uses the latest version of graphql where the fix has been implemented.

Please update to that version (or 1.5.0 once it's released) if you want this fixed

@jstejada This can be closed.

1.5.0-rc.1
I have updated my relay-compiler with a version 1.7.0 but still facing the same issue. Any suggestions?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luongthanhlam picture luongthanhlam  路  3Comments

amccloud picture amccloud  路  3Comments

derekdowling picture derekdowling  路  3Comments

MartinDawson picture MartinDawson  路  3Comments

mike-marcacci picture mike-marcacci  路  3Comments