graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

[vscode-graphql-syntax] Incorrect syntax highlighting after empty type implementing interface

Open LuudJanssen opened this issue 2 years ago • 1 comments

Current Behavior

After defining a type that implements an interface and which doesn't have a fields definition, the syntax highlighting breaks:

image

In this example you can see there's a difference in the syntax highlighting for the first object definition for Test and the second object definition for Test in the type keyword.

Expected Behavior

I would expect the syntax highlighting to be the same in both cases.

Possible fix

I noticed in graphql.json:79 that the regex for end is looking for a { symbol. The GraphQL Specs define the { symbol (part of fields definition) to be optional, making the regex incorrect.

I feel like the end regex should be a lookahead for a whitespace character. This would only highlight the implements keyword, but I think that's what's expected? If the definition itself should include the actual type defined (after the implements keyword), it could be a lookahead for whitespace character, that's not after a comma (to correctly highlight type Test implements InterfaceOne, InterfaceTwo).

LuudJanssen avatar Nov 06 '23 10:11 LuudJanssen

@LuudJanssen indeed, this seems to be the case - PRs are welcome! I haven't had a chance to work on syntax bugs in a while. I tend to oscillate slowly between graphiql and the LSP/vscode ecosystem because it's a lot of context! Feel free to open PRs for this and any issue with the label for the syntax extension!

acao avatar Nov 06 '23 19:11 acao