Skip to content

Add VSCode extension contributing GraphQLSP and GraphQL grammars#416

Open
JoviDeCroock wants to merge 3 commits into
mainfrom
JoviDeCroock/vscode-graphqlsp-plugin
Open

Add VSCode extension contributing GraphQLSP and GraphQL grammars#416
JoviDeCroock wants to merge 3 commits into
mainfrom
JoviDeCroock/vscode-graphqlsp-plugin

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

Summary

Adds packages/vscode-graphqlsp, a VSCode extension for GraphQLSP:

  • TypeScript server plugin: contributes @0no-co/graphqlsp to VSCode's built-in TypeScript language features via the typescriptServerPlugins contribution point (enableForWorkspaceTypeScriptVersions: true). Projects listing the plugin in their tsconfig.json keep their configuration and no longer need the plugin in their own node_modules — tsserver resolves it from the extension's bundled copy via plugin probe locations. tsserver skips the global copy when a project plugin with the same name exists, so nothing loads twice.
  • TextMate grammar + language configuration for .graphql/.gql/.graphqls files (operations, fragments, SDL, variables, directives, string/comment rules, etc.).
  • Injection grammar for inline GraphQL in JS/TS: gql`...`/graphql`...` tagged templates, gql(`...`)/graphql(`...`)/graphql.persisted(`...`) call expressions, and untagged templates starting with a #graphql comment. ${...} interpolations fall back to TypeScript expression highlighting.
  • Settings passthrough: graphqlsp.* editor settings mirror the plugin options and are forwarded through the TS extension's configurePlugin API for projects that don't configure the plugin in tsconfig.json; the extension offers a TS server restart when they change.

Plugin change

@0no-co/graphqlsp now detects being loaded as a global tsserver plugin (tsserver marks those config entries with global: true) without any schema/schemas configuration, and passes the language service through untouched. Without this, the editor-contributed plugin would surface "missing schema" configuration errors in every project that never set up GraphQLSP. Covered by a changeset (minor).

Packaging

pnpm --filter vscode-graphqlsp package builds a .vsix (verified: 1.09 MB). Since vsce can't package pnpm's symlinked node_modules, the script stages the extension with an npm-installed tarball of the workspace's graphqlsp, strips the typescript peer ranges (tsserver provides it at runtime; bundling it would add 23 MB), and runs vsce package there. @vscode/vsce's install scripts (keytar, @vscode/vsce-sign) are denied in pnpm-workspace.yaml — they only matter for marketplace publishing.

Test plan

  • pnpm build (rollup) and pnpm --filter vscode-graphqlsp build (tsc) pass
  • Both grammars validated with vscode-textmate + vscode-oniguruma: operations/fragments/SDL scopes, tagged templates, call expressions, #graphql markers, and ${...} substitutions all tokenize as intended
  • .vsix packaging verified end-to-end; bundle contains the plugin, graphql, and @gql.tada/internal, and no typescript
  • Manual: open packages/vscode-graphqlsp in VSCode, F5 → Extension Development Host, open packages/example (tsconfig-configured project) to see diagnostics/hovers; TS server log shows [GraphQLSP] entries

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 04a5d73

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

This PR includes changesets to release 1 package
Name Type
@0no-co/graphqlsp Minor

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

JoviDeCroock and others added 2 commits July 5, 2026 16:47
Adds packages/vscode-graphqlsp, a VSCode extension that:

- contributes @0no-co/graphqlsp to the built-in TypeScript language
  features as a tsserver plugin, so projects get diagnostics,
  completions, hover info, and go-to-definition without installing the
  plugin locally
- adds a TextMate grammar and language configuration for .graphql,
  .gql, and .graphqls files
- adds an injection grammar highlighting GraphQL in gql`...` and
  graphql`...` tagged templates, gql(`...`)/graphql(`...`) call
  expressions, and untagged templates starting with #graphql
- forwards graphqlsp.* editor settings to the plugin via the TS
  extension's configurePlugin API

The plugin itself now detects being loaded as a "global" tsserver
plugin without configuration and passes the language service through
untouched, so the extension doesn't surface configuration errors in
projects that never set up GraphQLSP.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The extension is already skipped as a private package, but this makes
the exclusion explicit and robust:

- list vscode-graphqlsp in the changesets ignore list, so neither
  changesets nor stage-packages ever considers it
- skip .staging directories in the release scripts' workspace walkers;
  the extension's vsix staging area contains a copy of its manifest
  with the private flag stripped

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JoviDeCroock JoviDeCroock force-pushed the JoviDeCroock/vscode-graphqlsp-plugin branch from c5a636b to 01638a8 Compare July 5, 2026 14:48
…gin instances

An editor-contributed ("global") GraphQLSP instance now resolves its
configuration per project instead of blindly using editor settings,
preventing conflicts between the two config sources:

- defer entirely when the project already runs a local GraphQLSP
  instance, detected via a Symbol.for marker on the language service
  proxy that survives separate module copies and covers
  gql.tada/ts-plugin
- adopt the project's tsconfig plugins entry when it exists but
  produced no instance (e.g. the package isn't installed locally)
- fall back to editor settings passed through configurePlugin, which
  the extension now always tags with editorContributed
- stay dormant when nothing is configured

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants