# coc-apollo

> coc.nvim extension for Apollo GraphQL

Latest version **0.4.9** (published 2022-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install coc-apollo
pnpm add coc-apollo
yarn add coc-apollo
bun add coc-apollo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.9 |
| Published | 2022-03-29 |
| First published | 2021-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 5.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ruanyl |
| Maintainers | ruanyu1 |
| Keywords | coc.nvim |

## Links

- npm: https://www.npmjs.com/package/coc-apollo
- npm.io page: https://npm.io/package/coc-apollo

## Dependencies (9)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [graphql](https://npm.io/package/graphql.md) ^15.5.0
- [cosmiconfig](https://npm.io/package/cosmiconfig.md) ^7.0.0
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.11.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [@types/lodash.merge](https://npm.io/package/@types/lodash.merge.md) ^4.6.6
- [graphql-language-service-server](https://npm.io/package/graphql-language-service-server.md) ^2.6.2
- [@endemolshinegroup/cosmiconfig-typescript-loader](https://npm.io/package/@endemolshinegroup/cosmiconfig-typescript-loader.md) ^3.0.2

## Recent versions

- 0.4.9 (latest) — 2022-03-29
- 0.4.8 — 2022-03-29
- 0.4.7 — 2021-06-12
- 0.4.6 — 2021-06-02
- 0.4.5 — 2021-05-10
- 0.4.4 — 2021-03-16
- 0.4.3 — 2021-03-16
- 0.4.2 — 2021-03-09
- 0.4.1 — 2021-02-22
- 0.4.0 — 2021-02-20
- 0.3.0 — 2021-02-20
- 0.2.3 — 2021-02-16
- 0.2.2 — 2021-02-15
- 0.2.0 — 2021-02-15
- 0.1.3 — 2021-02-15
- … 1 more at https://npm.io/package/coc-apollo/versions

## README

# 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](https://github.com/graphql/graphiql/blob/main/packages/graphql-language-service-server/README.md): 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](https://www.apollographql.com/docs/devtools/apollo-config/#option-2-link-a-schema-from-a-remote-endpoint)
4. Support loading schema from local: [example config](https://www.apollographql.com/docs/devtools/apollo-config/#option-3-link-a-schema-from-a-local-file)

### Service project
TODO...

## Setup
1. Add `APOLLO_KEY` to `.env`
2. Add [graphql-config](https://github.com/kamilkisiela/graphql-config) for graphql language server
3. (Optional) Add `apollo.config.json` or `apollo.config.js`, [config details](https://www.apollographql.com/docs/devtools/apollo-config/)
4. (Optional) Use [vim-graphql](https://github.com/jparise/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`
```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

## Configurations

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

## Setup status line
![statusline](https://user-images.githubusercontent.com/486382/108122730-69b42980-70ad-11eb-9c70-b99e216d2373.png)
```vimscript
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'
  \ }
\ }

```

## Lists

Show variant list: 
```
:CocList variants
```

## Commands
Reload Apollo graphql schema variant list
```
:CocCommand apollo.reload.variants
```

Reload Apollo field stats
```
:CocCommand apollo.reload.stats
```
## License

MIT

---

> This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension)

---
_Source: https://npm.io/package/coc-apollo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
