Skip to content

Commit dd2073a

Browse files
committed
chore: fix codemirror documentation
1 parent 93ef814 commit dd2073a

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

packages/codemirror-graphql/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ CodeMirror.fromTextArea(myTextarea, {
7979

8080
### Custom Validation Rules
8181

82-
If you want to show custom validation, you can do that too!
82+
If you want to show custom validation, you can do that too! It uses the `ValidationRule` interface.
8383

8484
```js
85-
import type { ValidationContext, SDLValidationContext } from 'graphql';
85+
import type { ValidationRule } from 'graphql';
8686

8787
import CodeMirror from 'codemirror';
8888
import 'codemirror/addon/hint/show-hint';
@@ -91,14 +91,17 @@ import 'codemirror-graphql/hint';
9191
import 'codemirror-graphql/lint';
9292
import 'codemirror-graphql/mode';
9393

94-
const ExampleRule = (context: ValidationContext | SDLValidationContext) => {
94+
const ExampleRule: ValidationRule = context => {
9595
// your custom rules here
9696
const schema = context.getSchema();
9797
const document = context.getDocument();
98-
// do stuff
99-
if (operationContainsCondition(document, schema)) {
100-
context.reportError('this contains the condition, oops!');
101-
}
98+
return {
99+
NamedType(node) {
100+
if (node.name.value !== node.name.value.toLowercase()) {
101+
context.reportError('only lowercase type names allowed!');
102+
}
103+
},
104+
};
102105
};
103106

104107
CodeMirror.fromTextArea(myTextarea, {

0 commit comments

Comments
 (0)