coc.nvim extension for Apollo GraphQL. Still work in progress, feedbacks and PRs are welcome.
:CocInstall coc-apollo
- GraphQL Language Server: autocomplete, diagnostics...
- Apollo GraphQL integration (Use the Apollo schema registry)
- Graph variants switching
- Performance stats (require
virtual text)
- Support loading schema from a remote endpoint, example config
- Support loading schema from local: example config
TODO...
- Add
APOLLO_KEYto.env - Add graphql-config for graphql language server
- (Optional) Add
apollo.config.jsonorapollo.config.js, config details - (Optional) Use vim-graphql for syntax highlighting
The plugin will download schema from Apollo Schema Registry/local schema/remote schema, it generates schema.graphql file by default. So you have to specify "schema": "schema.graphql" in the config in order for language server to read.
Example graphql.config.json
{
"schema": "schema.graphql"
}You can also customize the exported schema filename and type with :CocConfig
{
"apollo.schema.filename": "schema.json"
}
This will output the file in json format by converting the schema to schema introspection
apollo.defaultVariant the default apollo graph variant to download when the plugin been initially loaded, default: current
function! LightlineCocApolloStatus() abort
let status = get(g:, 'coc_apollo_current_variant', '')
if empty(status)
return ''
endif
return '🚀 ' . status
endfunction
let g:lightline = {
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename' ]
\ ],
\ 'right':[
\ [ 'filetype', 'lineinfo', 'percent', 'cocstatus' ],
\ [ 'cocapollo' ]
\ ],
\ },
\ 'component_function': {
\ 'cocapollo': 'LightlineCocApolloStatus'
\ }
\ }
Show variant list:
:CocList variants
Reload Apollo graphql schema variant list
:CocCommand apollo.reload.variants
Reload Apollo field stats
:CocCommand apollo.reload.stats
MIT
This extension is built with create-coc-extension
