Skip to content

Neovim

  1. Install the LSP server binary (see Installation)
  2. Install 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.*'
),
}

If the LSP server isn’t on your $PATH:

require('lspconfig').graphql.setup {
cmd = { '/path/to/graphql-lsp' },
}

Create a .graphqlrc.yml in your project root:

schema: schema.graphql
documents: src/**/*.{graphql,ts,tsx}

Check LSP logs:

:LspLog

Enable debug logging:

require('lspconfig').graphql.setup {
cmd = { 'graphql-lsp' },
cmd_env = {
RUST_LOG = 'debug',
},
}