@@ -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
8787import CodeMirror from ' codemirror' ;
8888import ' codemirror/addon/hint/show-hint' ;
@@ -91,14 +91,17 @@ import 'codemirror-graphql/hint';
9191import ' codemirror-graphql/lint' ;
9292import ' 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
104107CodeMirror .fromTextArea (myTextarea, {
0 commit comments