opencode
opencode copied to clipboard
Add GraphQL LSP server support
Feature Request
Add GraphQL Language Server Protocol (LSP) support to OpenCode to provide IDE-like features for GraphQL projects.
Problem
Currently, OpenCode doesn't have dedicated GraphQL LSP support. While Biome can handle .graphql/.gql files, it only provides linting - not the full LSP experience (autocomplete, hover info, go-to-definition, diagnostics against schema).
Proposed Solution
Add built-in GraphQL LSP server using graphql-language-service-cli (the official GraphQL LSP implementation) to provide:
- Diagnostics for GraphQL syntax linting and validation (spec-compliant)
- Autocomplete suggestions for fields, arguments, types, and variables
- Hover information showing field descriptions
- Go-to-definition for types, inputs, enums, and fragment definitions
- Support for inline GraphQL in JavaScript/TypeScript/Vue/Svelte/Astro files
Technical Details
-
LSP Server:
graphql-language-service-cli(providesgraphql-lspbinary) -
Command:
server -m stream(stream mode for LSP stdio communication) -
Extensions:
.graphql,.gql(standalone) +.ts,.tsx,.js,.jsx,.vue,.svelte,.astro(inline) -
Detection: Auto-detect via presence of GraphQL config files:
-
.graphqlrc.*(all formats: .yml, .yaml, .json, .js, .cjs, .mjs) -
graphql.config.*(all formats: .yml, .yaml, .json, .js, .cjs, .mjs)
-
-
Auto-installation: Install
graphql-language-service-cliglobally via bun if not found - Coexistence: Works alongside Biome and other LSPs without conflicts
References
- Official GraphQL LSP: https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli
- Similar to existing TailwindCSS LSP support (#9303)