-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated cm6-graphql package README #3127
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
18d2c9f
Update README.md
imolorhe 7f5d43a
Update README.md
imolorhe 3b1659c
Create .changeset/green-radios-fix.md
imolorhe 60fdfb2
Update packages/cm6-graphql/README.md
imolorhe 867974c
Update packages/cm6-graphql/README.md
imolorhe 585a3c5
Ran yarn pretty
imolorhe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"cm6-graphql": patch | ||
--- | ||
|
||
Updated cm6-graphql package README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1 +1,52 @@ | ||||||||||||||||||||||||||
# CodeMirror 6 GraphQL Language package | ||||||||||||||||||||||||||
# 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 a | ||||||||||||||||||||||||||
autocomplete and linting powered by your GraphQL Schema. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Getting Started | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```sh | ||||||||||||||||||||||||||
npm install --save cm6-graphql | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
[CodeMirror 6](https://codemirror.net/) customization is done through | ||||||||||||||||||||||||||
[extensions](https://codemirror.net/docs/guide/#extension). This package an | ||||||||||||||||||||||||||
extension that customizes codemirror 6 for GraphQL. | ||||||||||||||||||||||||||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```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. | ||||||||||||||||||||||||||
Comment on lines
+34
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Updating schema | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
If you need to update the GraphQL schema used in the editor dynamically, you can | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
call `updateSchema` with the CodeMirror `EditorView` instance and the new schema | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```js | ||||||||||||||||||||||||||
import { updateSchema } from 'cm6-graphql'; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const onNewSchema = schema => { | ||||||||||||||||||||||||||
updateSchema(view, schema); | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.