VS Code Integration (gqlschemagen-vscode)
The GQLSchemaGen VS Code extension makes working with your GraphQL schema even smoother by integrating schema generation directly into your editor. You don’t need to run CLI commands manually — you can trigger generation, inspect errors, and even see preserved schema blocks right from VS Code.
📦 Installation
- Open VS Code.
- Go to Extensions (left sidebar) or press
Ctrl+Shift+X(Cmd on Mac). - Search for “gqlschemagen” or browse for the extension ID:
pablor21.gqlschemagen-vscode. - Click Install.
- Reload VS Code if prompted.
Alternatively, you can install it via the Visual Studio Marketplace.
🚀 Usage
Once installed, you’ll have a few new ways to run schema generation directly from within VS Code:
- Use the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) and runGQLSchemaGen: Generate Schema. - If you have a
gqlschemagen.ymlconfig file, the extension will pick it up by default. - You can also run with a specific configuration file by passing its path.
When you run generation, the extension:
- Runs
gqlschemagen generatebehind the scenes - Captures any errors or warnings and shows them inside the Problems panel
- Overwrites the schema files while preserving your
@GqlKeepBegin / @GqlKeepEndblocks (if configured)
⚙️ Recommended Workflow
Here’s a sample workflow combining the extension with CLI and go:generate:
Then, in VS Code:
- Run
GQLSchemaGen: Generate Schemawhenever you've changed your Go models - Use
go generate ./...in your terminal (or via a task) to run both schema and resolver generation in one step
✅ What Makes the Extension Useful
- No context switch: run schema generation without leaving the editor
- Immediate feedback: errors show in Problems, inline
- Preservation: keeps your custom schema modifications intact
- Config-aware: uses
gqlschemagen.ymlif present
🔧 Troubleshooting & Tips
-
Config file not picked up? The extension looks for
gqlschemagen.ymlin your workspace root by default. If you use a different location, use a custom path in the command or workspace settings. -
Generation fails? Check the Output and Problems view — CLI errors are surfaced there just like from the terminal.
-
Keep-blocks overwritten? Ensure your markers (
@GqlKeepBegin/@GqlKeepEnd) match the ones configured in your YAML (by default# @GqlKeepBegin/# @GqlKeepEnd) so the extension can detect and preserve them properly.
💡 Why Use the Extension
- Streamlines schema updates as your Go code evolves
- Saves time by eliminating the need to switch back and forth between editor and terminal
- Encourages schema-first thinking, while keeping the schema auto-generated and DRY
Make sure to keep your extension updated via the VS Code marketplace to get the latest improvements and bug fixes.
That’s it for VS Code integration. Once you're set up, generating your schema from within the editor becomes a seamless part of your development workflow.