File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -241,3 +241,46 @@ The full list of available validators is:
241
241
- ` UniqueVariableNames `
242
242
- ` VariablesAreInputTypes `
243
243
- ` VariablesInAllowedPosition `
244
+
245
+ ### Named Operations Validation Rule
246
+
247
+ The Named Operation rule validates that all operations are named. Naming operations is valuable for including in server-side logs and debugging.
248
+
249
+ ** Pass**
250
+ ```
251
+ query FetchUsername {
252
+ viewer {
253
+ name
254
+ }
255
+ }
256
+ ```
257
+
258
+ ** Fail**
259
+ ```
260
+ query {
261
+ viewer {
262
+ name
263
+ }
264
+ }
265
+ ```
266
+
267
+ The rule is defined as ` graphql/named-operations ` and requires a ` schema ` and optional ` tagName `
268
+
269
+ ``` js
270
+ // In a file called .eslintrc.js
271
+ module .exports = {
272
+ parser: " babel-eslint" ,
273
+ rules: {
274
+ " graphql/template-strings" : [' error' , {
275
+ env: ' apollo' ,
276
+ schemaJson: require (' ./schema.json' ),
277
+ }],
278
+ " graphql/named-operations" : [' warning' {
279
+ schemaJson: require (' ./schema.json' ),
280
+ }],
281
+ },
282
+ plugins: [
283
+ ' graphql'
284
+ ]
285
+ }
286
+ ```
You can’t perform that action at this time.
0 commit comments