# cm6-graphql

> GraphQL language support for CodeMirror 6

Latest version **1.0.0** (published 2026-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install cm6-graphql
pnpm add cm6-graphql
yarn add cm6-graphql
bun add cm6-graphql
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-11-01 |
| First published | 2022-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 234.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 16939 |
| Maintainers | benjie, mjmahone, leebyron, i1g, acao |

## Links

- npm: https://www.npmjs.com/package/cm6-graphql
- Repository: https://github.com/graphql/graphiql
- Homepage: https://github.com/graphql/graphiql#readme
- Issues: https://github.com/graphql/graphiql/issues
- npm.io page: https://npm.io/package/cm6-graphql

## Dependencies (1)

- [graphql-language-service](https://npm.io/package/graphql-language-service.md) ^6.0.0

## Recent versions

- 1.0.0 (latest) — 2026-11-01
- 1.0.0-rc.1 (rc) — 2026-09-30
- 1.0.0-beta.1 (beta) — 2026-09-28
- 0.2.2-canary-be24c1cc.0 (canary) — 2025-07-17
- 0.0.9-alpha.0 (alpha) — 2023-06-20
- 1.0.0-rc.0 — 2026-09-28
- 1.0.0-beta.0 — 2026-09-26
- 0.2.2 — 2026-08-30
- 0.2.2-canary-3c41e521.0 — 2025-07-17
- 0.2.2-canary-018f3c73.0 — 2025-07-17
- 0.2.2-canary-9b31b224.0 — 2025-07-17
- 0.2.2-canary-23fbed22.0 — 2025-07-17
- 0.2.2-canary-5028aa1e.0 — 2025-07-17
- 0.2.2-canary-3146c50f.0 — 2025-07-17
- 0.2.2-canary-235e2d75.0 — 2025-07-17
- … 119 more at https://npm.io/package/cm6-graphql/versions

## README

# CodeMirror 6 GraphQL Language extension

[![NPM](https://img.shields.io/npm/v/cm6-graphql.svg?style=flat-square)](https://npmjs.com/cm6-graphql)
![npm downloads](https://img.shields.io/npm/dm/cm6-graphql?label=npm%20downloads)
[![License](https://img.shields.io/npm/l/cm6-graphql.svg?style=flat-square)](LICENSE)
[Discord Channel](https://discord.gg/cffZwk8NJW)

Provides CodeMirror 6 extension with a parser mode for GraphQL along with
autocomplete and linting powered by your GraphQL Schema.

### Getting Started

```sh
npm install cm6-graphql
```

[CodeMirror 6](https://codemirror.net/) customization is done through
[extensions](https://codemirror.net/docs/guide/#extension). This package is
an extension that customizes CodeMirror 6 for GraphQL.

```js
import { basicSetup, EditorView } from 'codemirror';
import { graphql } from 'cm6-graphql';

const view = new EditorView({
  doc: `mutation mutationName {
    setString(value: "newString")
  }`,
  extensions: [basicSetup, graphql(myGraphQLSchema)],
  parent: document.body,
});
```

_**Note:** You have to provide a theme to CodeMirror 6 for the styling you want. You
can take a look at
[this example](https://github.com/graphql/graphiql/blob/main/examples/cm6-graphql-parcel/src/index.ts)
or see the CodeMirror 6
[documentation examples](https://codemirror.net/examples/styling/) for more
details._

### Updating schema

If you need to dynamically update the GraphQL schema used in the editor, you can
call `updateSchema` with the CodeMirror `EditorView` instance and the new schema

```js
import { updateSchema } from 'cm6-graphql';

const onNewSchema = schema => {
  updateSchema(view, schema);
};
```

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