Neovim
Prerequisites
Section titled “Prerequisites”- Install the LSP server binary (see Installation)
- Install nvim-lspconfig
Setup with nvim-lspconfig
Section titled “Setup with nvim-lspconfig”Add to your init.lua:
require('lspconfig').graphql.setup { cmd = { 'graphql-lsp' }, filetypes = { 'graphql', 'typescript', 'typescriptreact', 'javascript', 'javascriptreact', 'vue', 'svelte', 'astro' }, root_dir = require('lspconfig.util').root_pattern( '.graphqlrc*', 'graphql.config.*' ),}Custom binary path
Section titled “Custom binary path”If the LSP server isn’t on your $PATH:
require('lspconfig').graphql.setup { cmd = { '/path/to/graphql-lsp' },}Configuration
Section titled “Configuration”Create a .graphqlrc.yml in your project root:
schema: schema.graphqldocuments: src/**/*.{graphql,ts,tsx}Debugging
Section titled “Debugging”Check LSP logs:
:LspLogEnable debug logging:
require('lspconfig').graphql.setup { cmd = { 'graphql-lsp' }, cmd_env = { RUST_LOG = 'debug', },}