apollographql / vscode-graphql

Apollo GraphQL VS Code extension
https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo
MIT License
62 stars 20 forks source link

Custom `tagName` is not respected in syntax highlighting #144

Closed pmooney-socraticworks closed 1 day ago

pmooney-socraticworks commented 2 months ago

I have an apollo.config.js file that looks like this:

module.exports = {
    client: {
        tagName: 'typedGraphql',
        ...
    },
};

I am using this property on the Apollo config to specify a unique tag name, since the code base I'm in has about 3 different libraries that export a graphql or gql tag name, as well as a decorated tag that I have created within my codebase. I want to improve DX by making sure unaware developers are importing the correct graphql tag (the one I created), rather than blindly auto-importing the wrong one, hence the unique tag name.

This works properly with the VSCode extension (I can navigate to fragment definitions, etc), however syntax highlighting does not respect the custom tag name. I have resorted to adding #graphql to the beginning of my template literal strings to recover the syntax highlighting.

Would it be possible to update the syntax highlighting to respect the custom tagName property please?

phryneas commented 1 month ago

Hi @pmooney-socraticworks!

I just looked into this, and unfortunately it seems impossible. Syntax highlighting in VSCode is done with Textmate Grammar files - and those are really static files.

There are feature requests in the VSCode repo (e.g. https://github.com/microsoft/vscode/issues/53885 ), but as for now, this is just not supported - and until they add that, I'm afraid, we cannot support dynamic tagName for syntax highlighting.

phryneas commented 1 day ago

Since this is something that we cannot do, I'm going to close this issue. Have a great day!