Js-graphql-intellij-plugin: .graphqls extension being requested for files

Created on 11 Jun 2017  路  3Comments  路  Source: jimkyndemeyer/js-graphql-intellij-plugin

Getting error in console for this plugin:
Warning:(2, 1) Schema definitions should be written in GraphQL Schema files (.graphqls)
Any idea what this is about? Should we keep using the .graphql or .graphqls?

Thank you.

screen shot 2017-06-11 at 14 23 36

Most helpful comment

I have run into this problem too. I think .graphql should be supported as its what facebook uses internally (https://github.com/facebook/graphql/issues/203)

All 3 comments

I have run into this problem too. I think .graphql should be supported as its what facebook uses internally (https://github.com/facebook/graphql/issues/203)

When I initially developed this plugin, Facebook didn't have any open source IDE support for GraphQL outside of the browser-based GraphiQL.

The reason why there's separate file extensions has to do with how an IDE like IntelliJ IDEA/WebStorm provides the following features:

  • Error markers
  • Completion
  • Go to definition
  • Actions such as query execution

Regarding error markers, there are different valid keywords depending on whether you're writing executable GraphQL or the GraphQL Schema IDL. For example, the "type" keyword is neither executable nor does it validate when sent to GraphQL endpoint.

Similar syntactic and semantic differences apply for completion and go to definition. The only way for the IDE to know the difference is based on the file extension. So I basically followed the same logic as was used to define .jsx as a separate extension from .js.

If I had to guess, FB kept things simple and only used .graphql because they've had no reason to do otherwise before IDE support was established.

@asiandrummer Your thoughts on this? And correct me if I'm mistaken on FB internals :)

@jimkyndemeyer whoa sorry! I'm super late to this party ;) let me provide some context hoping to be of some help understanding.

GraphQL schema IDL definition support came a while later the open source of GraphQL (hence GraphiQL) happened, therefore the online parser (which I believe this plugin is using) and the graphql-js parser did not begin with the support for schema IDL at the time. GraphQL treats schema IDL as the part of the GraphQL syntax specification. I think @jimkyndemeyer's schema definition syntax support came earlier than GraphQL's schema IDL support, hence the differences.

Since we can treat type extensions/definitions as parts of queries/GraphQL artifacts, there's really no need to have a different file extensions (although you'd want the schema related definitions in a different file, just like schema.graphql that you have above). Parsing the syntax and validation steps for schema IDL language function as same as a regular GraphQL query (except for the part where you have to extend with your type def/exts to validate the schema).

@jimkyndemeyer would you be interested in supporting GraphQL schema IDL in place for your schema definition syntax?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MegaJSDeveloper picture MegaJSDeveloper  路  3Comments

oknesar picture oknesar  路  5Comments

MaxmaxmaximusAWS picture MaxmaxmaximusAWS  路  4Comments

jamiter picture jamiter  路  3Comments

victororlyk picture victororlyk  路  3Comments