项目作者: ruanyl

项目描述 :
coc.nvim extension for GraphQL/Apollo GraphQL
高级语言: TypeScript
项目地址: git://github.com/ruanyl/coc-apollo.git
创建时间: 2019-10-13T20:11:14Z
项目社区:https://github.com/ruanyl/coc-apollo

开源协议:MIT License

下载


coc-apollo (WIP)

coc.nvim extension for Apollo GraphQL. Still work in progress, feedbacks and PRs are welcome.

Install

:CocInstall coc-apollo

Features

Client Project

  1. GraphQL Language Server: autocomplete, diagnostics…
  2. Apollo GraphQL integration (Use the Apollo schema registry)
    • Graph variants switching
    • Performance stats (require virtual text)
  3. Support loading schema from a remote endpoint, example config
  4. Support loading schema from local: example config

Service project

TODO…

Setup

  1. Add APOLLO_KEY to .env
  2. Add graphql-config for graphql language server
  3. (Optional) Add apollo.config.json or apollo.config.js, config details
  4. (Optional) Use vim-graphql for syntax highlighting

Configure graphql.config.json

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

  1. {
  2. "schema": "schema.graphql"
  3. }

You can also customize the exported schema filename and type with :CocConfig

  1. {
  2. "apollo.schema.filename": "schema.json"
  3. }

This will output the file in json format by converting the schema to schema introspection

Configurations

apollo.defaultVariant the default apollo graph variant to download when the plugin been initially loaded, default: current

Setup status line

statusline

  1. function! LightlineCocApolloStatus() abort
  2. let status = get(g:, 'coc_apollo_current_variant', '')
  3. if empty(status)
  4. return ''
  5. endif
  6. return '🚀 ' . status
  7. endfunction
  8. let g:lightline = {
  9. \ 'active': {
  10. \ 'left': [
  11. \ [ 'mode', 'paste' ],
  12. \ [ 'readonly', 'filename' ]
  13. \ ],
  14. \ 'right':[
  15. \ [ 'filetype', 'lineinfo', 'percent', 'cocstatus' ],
  16. \ [ 'cocapollo' ]
  17. \ ],
  18. \ },
  19. \ 'component_function': {
  20. \ 'cocapollo': 'LightlineCocApolloStatus'
  21. \ }
  22. \ }

Lists

Show variant list:

  1. :CocList variants

Commands

Reload Apollo graphql schema variant list

  1. :CocCommand apollo.reload.variants

Reload Apollo field stats

  1. :CocCommand apollo.reload.stats

License

MIT


This extension is built with create-coc-extension