@@ -33,7 +33,7 @@ type. But if you wish to use JavaScript - that's fine :)
3333
3434Here's an example for a simple rule that reports on anonymous GraphQL operations:
3535
36- ``` ts filename="your -rule-name .ts"
36+ ``` ts filename="my -rule.ts"
3737import { GraphQLESLintRule } from ' @graphql-eslint/eslint-plugin'
3838
3939const rule: GraphQLESLintRule = {
@@ -82,7 +82,7 @@ objects.
8282
8383Here's an example for using original ` graphql-js ` validate method to validate ` OperationDefinition ` :
8484
85- ``` ts filename="your -rule-name .ts"
85+ ``` ts filename="my -rule.ts"
8686import { validate } from ' graphql'
8787import { requireGraphQLSchemaFromContext } from ' @graphql-eslint/eslint-plugin'
8888
@@ -131,12 +131,12 @@ call `requireGraphQLSchemaFromContext` - it will validate that the schema is loa
131131` typeInfo ` is provided on every node, based on the type of that node, for example, to access the
132132` GraphQLOutputType ` while you are visiting a ` SelectionSet ` node, you can do:
133133
134- ``` ts filename="your -rule-name .ts"
134+ ``` ts filename="my -rule.ts"
135135import { requireGraphQLSchemaFromContext } from ' @graphql-eslint/eslint-plugin'
136136
137137export const rule = {
138138 create(context ) {
139- requireGraphQLSchemaFromContext (' your -rule-name ' , context )
139+ requireGraphQLSchemaFromContext (' my -rule' , context )
140140
141141 return {
142142 SelectionSet(node ) {
@@ -163,13 +163,28 @@ of ESLint.
163163The wrapped ` GraphQLRuleTester ` provides built-in configured parser, and a schema loader, if you
164164need to test your rule with a loaded schema.
165165
166- ``` ts filename="your-rule-name.spec.ts"
167- import { GraphQLRuleTester } from ' @graphql-eslint/eslint-plugin'
166+ ``` ts filename="my-rule.test.ts"
167+ import { parser } from ' @graphql-eslint/eslint-plugin'
168+ import { RuleTester } from ' eslint' ;
168169import { rule } from ' ./my-rule'
169170
170- const ruleTester = new GraphQLRuleTester ()
171-
172- ruleTester .runGraphQLTests (' your-rule-name' , rule , {
171+ const ruleTester = new RuleTester ({
172+ languageOptions: {
173+ parser ,
174+ parserOptions: {
175+ graphQLConfig: {
176+ schema: /* GraphQL */ `
177+ # Optionally, your schema, your rule could have access to it
178+ ` ,
179+ documents: /* GraphQL */ `
180+ # Optionally, your operations, your rule could have access to them
181+ ` ,
182+ },
183+ },
184+ },
185+ });
186+
187+ ruleTester .run (' my-rule' , rule , {
173188 valid: [
174189 {
175190 code: ' query something { foo }'
0 commit comments