Skip to content

fix(vscode-graphql-syntax): don't highlight .graphql() member calls as embedded GraphQL#4415

Open
mvanhorn wants to merge 4 commits into
graphql:mainfrom
mvanhorn:fix/3810-graphql-method-syntax-highlight
Open

fix(vscode-graphql-syntax): don't highlight .graphql() member calls as embedded GraphQL#4415
mvanhorn wants to merge 4 commits into
graphql:mainfrom
mvanhorn:fix/3810-graphql-method-syntax-highlight

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

The vscode-graphql-syntax TextMate grammar treated a bare graphql / gql identifier as an embedded-GraphQL trigger even when it appeared as a member access, so client.graphql<Response>(...) and foo.graphql() were highlighted as embedded GraphQL and broke downstream JS/TS scoping (regression from #3540). This restricts the trigger to genuine tagged-template / helper calls.

Why

The injection regex now requires the keyword not to be preceded by a member/identifier boundary, so member calls (.graphql(), private #graphql()) are excluded, and it preserves quoted angle brackets inside generic arguments (graphql<Result<User>>(...)). Cross-line member access is handled as far as a single-line TextMate grammar can. The bulk of the diff is regenerated tokenizer snapshots reflecting the corrected scoping.

Testing

vitest run tests/js-grammar.spec.ts in packages/vscode-graphql-syntax -- passes, with fixtures added for member calls, private-member calls, and generic arguments.

Closes #3810

mvanhorn added 3 commits July 11, 2026 05:22
…s embedded GraphQL

The function-call injection regex matched a bare `graphql`/`gql` identifier
even when it appeared as a member access, so `client.graphql<Response>(...)`
and `foo.graphql()` were swallowed as embedded GraphQL blocks and broke
downstream JS/TS scoping (regression from graphql#3540, v1.3.5). Add a negative
lookbehind so the keyword only triggers when it is not preceded by `.`, `$`,
or a word character, and make the generic-arguments matcher non-greedy.

Closes graphql#3810
Preserve quoted angle brackets in generic arguments, exclude private #graphql
member calls, and handle cross-line member dots; regenerate snapshots and add
coverage.
@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e38d5c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vscode-graphql-syntax Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 12, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

The syntax-highlighting fixtures deliberately contain unformatted constructs (multiline member access, space and comment between the dot and method name) that the grammar tests assert against; formatting them would erase what they test. cspell flagged the POSIX class [:alnum:] in the grammar fixture.
@mvanhorn

Copy link
Copy Markdown
Author

Fixed the CSpell and Format checks in e38d5c8. CSpell was flagging alnum from the POSIX class [_$[:alnum:]] in the grammar fixture, so it's in the custom word list now. For Format: oxfmt wanted to rewrite the test fixtures, but that would erase exactly what they test (the multiline member split, the client. graphql space, the comment between the dot and the method name), so I excluded tests/__fixtures__/** in .oxfmtrc.json instead — grammar fixtures need their exact source text preserved. The Canary Builds failure looks like a registry hiccup (Cloudflare error page in the log); this push re-runs it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[graphiql] Syntax highlighting breaks with .graphql as a function

1 participant