graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
557 stars 71 forks source link

Support /* GraphQL */ template string comment tags #232

Closed jaydenseric closed 2 years ago

jaydenseric commented 4 years ago

Actual Behavior

This template string is not treated as GraphQL:

const query = /* GraphQL */ `
  {
    foo
  }
`

But this one is:

const query = `#graphql
  {
    foo
  }
`

Expected Behavior

The de facto industry standard method for declaring the language of the contents of a template string is a comment before the actual string (i.e. /* GraphQL */ `). This convention is superior to modifying the actual contents of the string and is used by lots of tools (e.g. Prettier) and should be supported by this VS Code extension.

With `#graphql the #graphql comment will bloat the query sent in the GraphQL request over the network. This method should not be supported by this VS Code extension.

What is the history/context behind this commit that first documented the `#graphql support?

https://github.com/graphql/vscode-graphql/commit/118a60c3437513508c24ce64e75112a211155c22#diff-04c6e90faac2675aa89e2176d2eec7d8R177-R198

acao commented 3 years ago

this is where it was introduced: https://github.com/graphql/vscode-graphql/commit/759cef63ae8f55a04c6f1f0386e4c699574d8dbd

apollo vscode extension has it as well. i was planning on adding support for this pattern as well but not have had time

if you wanted to help me out with a PR to src/grammars/graphql.js.json, to add another declaration similar to that one, be my guest!