Neovim nvim-cmp source for graphql completions based on schema
Example -
use 'phenax/cmp-graphql'
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
require('cmp-graphql').setup({
schema_path = 'graphql.schema.json', -- Path to generated json schema file in project
})