/cmp-graphql

Neovim nvim-cmp source for graphql completions based on schema

Primary LanguageLuaMIT LicenseMIT

cmp-graphql

Neovim nvim-cmp source for graphql completions based on schema

Instructions

Install phenax/cmp-graphql using your plugin manager

Example -

use 'phenax/cmp-graphql'

Add graphql source to your cmp config

cmp.setup({
  -- ...
  sources = {
    -- ...
    { name = 'graphql' }
  }
})

Generate schema json file (Using @graphql-codegen/cli)

  • Install @graphql-codegen/cli
yarn add -D @graphql-codegen/cli
  • Run codegen init to setup the codegen config file

NOTE: Make sure introspection json is enabled. The only relevant generated file is the schema json file.

yarn graphql-codegen init
  • And then to generate the schema json file
yarn && yarn codegen

Setup cmp-graphql for your project with

require('cmp-graphql').setup({
  schema_path = 'graphql.schema.json', -- Path to generated json schema file in project
})