Mayank1791989 / gql

112 stars 19 forks source link

Schema syntax highlighting doesn't work when extension something other than ".gql" #77

Closed aneilbaboo closed 6 years ago

aneilbaboo commented 6 years ago

How can I get syntax highlighting for schema files with extensions other than ".gql"?

For example, https://github.com/sysgears/apollo-universal-starter-kit has schema files named schema.graphqls.

I expected the following .gqlconfig file to work. The file is recognized (I get documentation popovers, which I'm unable to screencap, but trust me, they're there), however, the syntax isn't highlighted. If I change my gqlconfig schema files to '**/schema.gql', rename the extension to .gql and reload, I see syntax highlighting.

// .gqlconfig (with query)
{
  schema: {
    files: '**/schema.graphqls'
  },
  query: {
    files: [
      // query gql files
      {
        match: 'src/**/*.gql',
        parser: 'QueryParser',
      },
      // [Embedded queries] relay files
      {
        match: { include: 'src/**/*.js', ignore: '**/*.spec.js' },
        parser: [ 'EmbeddedQueryParser', { startTag: 'Relay\\.QL`', endTag: '`' } ],
        isRelay: true,
      },
      // [Embedded queries] gql tag files
      {
        match: { include: 'src/**/*.js', ignore: '**/*.spec.js' },
        parser: [ 'EmbeddedQueryParser', { startTag: 'gql`', endTag: '`' } ],
      }
    ]
  }
}
kumarharsh commented 6 years ago

The syntax highlighting is controlled by the graphql-for-vscode plugin. I'll add support for graphqls over the weekend. Thanks for the report.

aneilbaboo commented 6 years ago

Great, thanks @kumarharsh. What do you think of turning on syntax highlighting automatically for files listed in .gqlconfig glob patterns? That's how I expected it to work. If vscode makes that hard or impossible to do, it would be worth listing the hard-coded files types in the documentation.

aneilbaboo commented 6 years ago

Closing in favor of https://github.com/kumarharsh/graphql-for-vscode/issues/58