@graphql-eslint/eslint-plugin 3.14.0-alpha-20221220004017-f1f0904 → 3.14.0-alpha-20221220160018-ba4832c
Sign up to get free protection for your applications and to get access to all the features.
- package/configs/operations-all.json +1 -0
- package/index.js +596 -467
- package/index.mjs +597 -468
- package/package.json +1 -1
- package/rules/alphabetize.d.ts +65 -14
- package/rules/description-style.d.ts +18 -4
- package/rules/index.d.ts +76 -18
- package/rules/input-name.d.ts +33 -7
- package/rules/lone-executable-definition.d.ts +26 -0
- package/rules/match-document-filename.d.ts +65 -13
- package/rules/naming-convention.d.ts +80 -34
- package/rules/no-anonymous-operations.d.ts +1 -2
- package/rules/no-case-insensitive-enum-values-duplicates.d.ts +1 -2
- package/rules/no-deprecated.d.ts +1 -2
- package/rules/no-duplicate-fields.d.ts +1 -2
- package/rules/no-hashtag-description.d.ts +1 -2
- package/rules/no-root-type.d.ts +23 -5
- package/rules/no-scalar-result-type-on-mutation.d.ts +1 -2
- package/rules/no-typename-prefix.d.ts +1 -2
- package/rules/no-unreachable-types.d.ts +1 -2
- package/rules/no-unused-fields.d.ts +1 -2
- package/rules/relay-arguments.d.ts +19 -4
- package/rules/relay-connection-types.d.ts +1 -2
- package/rules/relay-edge-types.d.ts +29 -6
- package/rules/relay-page-info.d.ts +1 -2
- package/rules/require-deprecation-date.d.ts +17 -4
- package/rules/require-deprecation-reason.d.ts +1 -2
- package/rules/require-description.d.ts +10 -7
- package/rules/require-field-of-type-query-in-mutation-result.d.ts +1 -2
- package/rules/require-id-when-available.d.ts +34 -4
- package/rules/selection-set-depth.d.ts +26 -5
- package/rules/strict-id-in-types.d.ts +54 -8
- package/rules/unique-fragment-name.d.ts +1 -2
- package/rules/unique-operation-name.d.ts +1 -2
- package/testkit.d.ts +1 -1
- package/types.d.ts +3 -1
- package/utils.d.ts +1 -0
package/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { gqlPluckFromCodeStringSync } from '@graphql-tools/graphql-tag-pluck';
|
2
|
-
import { asArray, getDocumentNodeFromSchema, parseGraphQLSDL } from '@graphql-tools/utils';
|
2
|
+
import { asArray, getDocumentNodeFromSchema, getRootTypeNames, parseGraphQLSDL } from '@graphql-tools/utils';
|
3
3
|
import { dirname, extname, basename, relative, resolve } from 'path';
|
4
4
|
import debugFactory from 'debug';
|
5
5
|
import { loadConfigSync, GraphQLConfig } from 'graphql-config';
|
@@ -328,7 +328,7 @@ const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasD
|
|
328
328
|
...docs,
|
329
329
|
graphQLJSRuleName: ruleName,
|
330
330
|
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${ruleId}.md`,
|
331
|
-
description: `${docs.description}\n
|
331
|
+
description: `${docs.description}\n> This rule is a wrapper around a \`graphql-js\` validation function.`,
|
332
332
|
},
|
333
333
|
schema,
|
334
334
|
hasSuggestions: hasDidYouMeanSuggestions,
|
@@ -503,7 +503,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
503
503
|
ruleName: 'LoneAnonymousOperation',
|
504
504
|
}, {
|
505
505
|
category: 'Operations',
|
506
|
-
description: 'A GraphQL document
|
506
|
+
description: 'A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if it contains only that one operation definition.',
|
507
507
|
requiresSchema: true,
|
508
508
|
}), validationToRule({
|
509
509
|
ruleId: 'lone-schema-definition',
|
@@ -727,6 +727,58 @@ const argumentsEnum = [
|
|
727
727
|
Kind.DIRECTIVE_DEFINITION,
|
728
728
|
Kind.DIRECTIVE,
|
729
729
|
];
|
730
|
+
const schema = {
|
731
|
+
type: 'array',
|
732
|
+
minItems: 1,
|
733
|
+
maxItems: 1,
|
734
|
+
items: {
|
735
|
+
type: 'object',
|
736
|
+
additionalProperties: false,
|
737
|
+
minProperties: 1,
|
738
|
+
properties: {
|
739
|
+
fields: {
|
740
|
+
...ARRAY_DEFAULT_OPTIONS,
|
741
|
+
items: {
|
742
|
+
enum: fieldsEnum,
|
743
|
+
},
|
744
|
+
description: 'Fields of `type`, `interface`, and `input`.',
|
745
|
+
},
|
746
|
+
values: {
|
747
|
+
...ARRAY_DEFAULT_OPTIONS,
|
748
|
+
items: {
|
749
|
+
enum: valuesEnum,
|
750
|
+
},
|
751
|
+
description: 'Values of `enum`.',
|
752
|
+
},
|
753
|
+
selections: {
|
754
|
+
...ARRAY_DEFAULT_OPTIONS,
|
755
|
+
items: {
|
756
|
+
enum: selectionsEnum,
|
757
|
+
},
|
758
|
+
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
759
|
+
},
|
760
|
+
variables: {
|
761
|
+
...ARRAY_DEFAULT_OPTIONS,
|
762
|
+
items: {
|
763
|
+
enum: variablesEnum,
|
764
|
+
},
|
765
|
+
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
766
|
+
},
|
767
|
+
arguments: {
|
768
|
+
...ARRAY_DEFAULT_OPTIONS,
|
769
|
+
items: {
|
770
|
+
enum: argumentsEnum,
|
771
|
+
},
|
772
|
+
description: 'Arguments of fields and directives.',
|
773
|
+
},
|
774
|
+
definitions: {
|
775
|
+
type: 'boolean',
|
776
|
+
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
777
|
+
default: false,
|
778
|
+
},
|
779
|
+
},
|
780
|
+
},
|
781
|
+
};
|
730
782
|
const rule = {
|
731
783
|
meta: {
|
732
784
|
type: 'suggestion',
|
@@ -833,58 +885,7 @@ const rule = {
|
|
833
885
|
messages: {
|
834
886
|
[RULE_ID]: '`{{ currName }}` should be before {{ prevName }}.',
|
835
887
|
},
|
836
|
-
schema
|
837
|
-
type: 'array',
|
838
|
-
minItems: 1,
|
839
|
-
maxItems: 1,
|
840
|
-
items: {
|
841
|
-
type: 'object',
|
842
|
-
additionalProperties: false,
|
843
|
-
minProperties: 1,
|
844
|
-
properties: {
|
845
|
-
fields: {
|
846
|
-
...ARRAY_DEFAULT_OPTIONS,
|
847
|
-
items: {
|
848
|
-
enum: fieldsEnum,
|
849
|
-
},
|
850
|
-
description: 'Fields of `type`, `interface`, and `input`.',
|
851
|
-
},
|
852
|
-
values: {
|
853
|
-
...ARRAY_DEFAULT_OPTIONS,
|
854
|
-
items: {
|
855
|
-
enum: valuesEnum,
|
856
|
-
},
|
857
|
-
description: 'Values of `enum`.',
|
858
|
-
},
|
859
|
-
selections: {
|
860
|
-
...ARRAY_DEFAULT_OPTIONS,
|
861
|
-
items: {
|
862
|
-
enum: selectionsEnum,
|
863
|
-
},
|
864
|
-
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
865
|
-
},
|
866
|
-
variables: {
|
867
|
-
...ARRAY_DEFAULT_OPTIONS,
|
868
|
-
items: {
|
869
|
-
enum: variablesEnum,
|
870
|
-
},
|
871
|
-
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
872
|
-
},
|
873
|
-
arguments: {
|
874
|
-
...ARRAY_DEFAULT_OPTIONS,
|
875
|
-
items: {
|
876
|
-
enum: argumentsEnum,
|
877
|
-
},
|
878
|
-
description: 'Arguments of fields and directives.',
|
879
|
-
},
|
880
|
-
definitions: {
|
881
|
-
type: 'boolean',
|
882
|
-
description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
|
883
|
-
default: false,
|
884
|
-
},
|
885
|
-
},
|
886
|
-
},
|
887
|
-
},
|
888
|
+
schema,
|
888
889
|
},
|
889
890
|
create(context) {
|
890
891
|
var _a, _b, _c, _d, _e;
|
@@ -1027,6 +1028,21 @@ const rule = {
|
|
1027
1028
|
},
|
1028
1029
|
};
|
1029
1030
|
|
1031
|
+
const schema$1 = {
|
1032
|
+
type: 'array',
|
1033
|
+
maxItems: 1,
|
1034
|
+
items: {
|
1035
|
+
type: 'object',
|
1036
|
+
additionalProperties: false,
|
1037
|
+
minProperties: 1,
|
1038
|
+
properties: {
|
1039
|
+
style: {
|
1040
|
+
enum: ['block', 'inline'],
|
1041
|
+
default: 'block',
|
1042
|
+
},
|
1043
|
+
},
|
1044
|
+
},
|
1045
|
+
};
|
1030
1046
|
const rule$1 = {
|
1031
1047
|
meta: {
|
1032
1048
|
type: 'suggestion',
|
@@ -1059,18 +1075,7 @@ const rule$1 = {
|
|
1059
1075
|
url: 'https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/description-style.md',
|
1060
1076
|
recommended: true,
|
1061
1077
|
},
|
1062
|
-
schema:
|
1063
|
-
{
|
1064
|
-
type: 'object',
|
1065
|
-
additionalProperties: false,
|
1066
|
-
properties: {
|
1067
|
-
style: {
|
1068
|
-
enum: ['block', 'inline'],
|
1069
|
-
default: 'block',
|
1070
|
-
},
|
1071
|
-
},
|
1072
|
-
},
|
1073
|
-
],
|
1078
|
+
schema: schema$1,
|
1074
1079
|
},
|
1075
1080
|
create(context) {
|
1076
1081
|
const { style = 'block' } = context.options[0] || {};
|
@@ -1099,6 +1104,36 @@ const rule$1 = {
|
|
1099
1104
|
},
|
1100
1105
|
};
|
1101
1106
|
|
1107
|
+
const schema$2 = {
|
1108
|
+
type: 'array',
|
1109
|
+
maxItems: 1,
|
1110
|
+
items: {
|
1111
|
+
type: 'object',
|
1112
|
+
additionalProperties: false,
|
1113
|
+
properties: {
|
1114
|
+
checkInputType: {
|
1115
|
+
type: 'boolean',
|
1116
|
+
default: false,
|
1117
|
+
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1118
|
+
},
|
1119
|
+
caseSensitiveInputType: {
|
1120
|
+
type: 'boolean',
|
1121
|
+
default: true,
|
1122
|
+
description: 'Allow for case discrepancies in the input type name',
|
1123
|
+
},
|
1124
|
+
checkQueries: {
|
1125
|
+
type: 'boolean',
|
1126
|
+
default: false,
|
1127
|
+
description: 'Apply the rule to Queries',
|
1128
|
+
},
|
1129
|
+
checkMutations: {
|
1130
|
+
type: 'boolean',
|
1131
|
+
default: true,
|
1132
|
+
description: 'Apply the rule to Mutations',
|
1133
|
+
},
|
1134
|
+
},
|
1135
|
+
},
|
1136
|
+
};
|
1102
1137
|
const isObjectType = (node) => [Kind.OBJECT_TYPE_DEFINITION, Kind.OBJECT_TYPE_EXTENSION].includes(node.type);
|
1103
1138
|
const isQueryType = (node) => isObjectType(node) && node.name.value === 'Query';
|
1104
1139
|
const isMutationType = (node) => isObjectType(node) && node.name.value === 'Mutation';
|
@@ -1140,34 +1175,7 @@ const rule$2 = {
|
|
1140
1175
|
},
|
1141
1176
|
],
|
1142
1177
|
},
|
1143
|
-
schema:
|
1144
|
-
{
|
1145
|
-
type: 'object',
|
1146
|
-
additionalProperties: false,
|
1147
|
-
properties: {
|
1148
|
-
checkInputType: {
|
1149
|
-
type: 'boolean',
|
1150
|
-
default: false,
|
1151
|
-
description: 'Check that the input type name follows the convention <mutationName>Input',
|
1152
|
-
},
|
1153
|
-
caseSensitiveInputType: {
|
1154
|
-
type: 'boolean',
|
1155
|
-
default: true,
|
1156
|
-
description: 'Allow for case discrepancies in the input type name',
|
1157
|
-
},
|
1158
|
-
checkQueries: {
|
1159
|
-
type: 'boolean',
|
1160
|
-
default: false,
|
1161
|
-
description: 'Apply the rule to Queries',
|
1162
|
-
},
|
1163
|
-
checkMutations: {
|
1164
|
-
type: 'boolean',
|
1165
|
-
default: true,
|
1166
|
-
description: 'Apply the rule to Mutations',
|
1167
|
-
},
|
1168
|
-
},
|
1169
|
-
},
|
1170
|
-
],
|
1178
|
+
schema: schema$2,
|
1171
1179
|
},
|
1172
1180
|
create(context) {
|
1173
1181
|
const options = {
|
@@ -1229,9 +1237,92 @@ const rule$2 = {
|
|
1229
1237
|
},
|
1230
1238
|
};
|
1231
1239
|
|
1240
|
+
const RULE_ID$1 = 'lone-executable-definition';
|
1241
|
+
const schema$3 = {
|
1242
|
+
type: 'array',
|
1243
|
+
maxItems: 1,
|
1244
|
+
items: {
|
1245
|
+
type: 'object',
|
1246
|
+
minProperties: 1,
|
1247
|
+
additionalProperties: false,
|
1248
|
+
properties: {
|
1249
|
+
ignore: {
|
1250
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1251
|
+
maxItems: 3,
|
1252
|
+
items: {
|
1253
|
+
enum: ['fragment', 'query', 'mutation', 'subscription'],
|
1254
|
+
},
|
1255
|
+
description: 'Allow certain definitions to be placed alongside others.',
|
1256
|
+
},
|
1257
|
+
},
|
1258
|
+
},
|
1259
|
+
};
|
1260
|
+
const rule$3 = {
|
1261
|
+
meta: {
|
1262
|
+
type: 'suggestion',
|
1263
|
+
docs: {
|
1264
|
+
category: 'Operations',
|
1265
|
+
description: 'Require all queries, mutations, subscriptions and fragments to be located in separate files.',
|
1266
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$1}.md`,
|
1267
|
+
examples: [
|
1268
|
+
{
|
1269
|
+
title: 'Incorrect',
|
1270
|
+
code: /* GraphQL */ `
|
1271
|
+
query Foo {
|
1272
|
+
id
|
1273
|
+
}
|
1274
|
+
fragment Bar on Baz {
|
1275
|
+
id
|
1276
|
+
}
|
1277
|
+
`,
|
1278
|
+
},
|
1279
|
+
{
|
1280
|
+
title: 'Correct',
|
1281
|
+
code: /* GraphQL */ `
|
1282
|
+
query Foo {
|
1283
|
+
id
|
1284
|
+
}
|
1285
|
+
`,
|
1286
|
+
},
|
1287
|
+
],
|
1288
|
+
},
|
1289
|
+
messages: {
|
1290
|
+
[RULE_ID$1]: '{{name}} should be in a separate file.',
|
1291
|
+
},
|
1292
|
+
schema: schema$3,
|
1293
|
+
},
|
1294
|
+
create(context) {
|
1295
|
+
var _a;
|
1296
|
+
const ignore = new Set(((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.ignore) || []);
|
1297
|
+
const definitions = [];
|
1298
|
+
return {
|
1299
|
+
':matches(OperationDefinition, FragmentDefinition)'(node) {
|
1300
|
+
const type = 'operation' in node ? node.operation : 'fragment';
|
1301
|
+
if (!ignore.has(type)) {
|
1302
|
+
definitions.push({ type, node });
|
1303
|
+
}
|
1304
|
+
},
|
1305
|
+
'Program:exit'() {
|
1306
|
+
var _a, _b;
|
1307
|
+
for (const { node, type } of definitions.slice(1) /* ignore first definition */) {
|
1308
|
+
let name = pascalCase(type);
|
1309
|
+
const definitionName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
|
1310
|
+
if (definitionName) {
|
1311
|
+
name += ` "${definitionName}"`;
|
1312
|
+
}
|
1313
|
+
context.report({
|
1314
|
+
loc: ((_b = node.name) === null || _b === void 0 ? void 0 : _b.loc) || getLocation(node.loc.start, type),
|
1315
|
+
messageId: RULE_ID$1,
|
1316
|
+
data: { name },
|
1317
|
+
});
|
1318
|
+
}
|
1319
|
+
},
|
1320
|
+
};
|
1321
|
+
},
|
1322
|
+
};
|
1323
|
+
|
1232
1324
|
const MATCH_EXTENSION = 'MATCH_EXTENSION';
|
1233
1325
|
const MATCH_STYLE = 'MATCH_STYLE';
|
1234
|
-
const ACCEPTED_EXTENSIONS = ['.gql', '.graphql'];
|
1235
1326
|
const CASE_STYLES = [
|
1236
1327
|
'camelCase',
|
1237
1328
|
'PascalCase',
|
@@ -1243,7 +1334,39 @@ const CASE_STYLES = [
|
|
1243
1334
|
const schemaOption = {
|
1244
1335
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1245
1336
|
};
|
1246
|
-
const
|
1337
|
+
const schema$4 = {
|
1338
|
+
definitions: {
|
1339
|
+
asString: {
|
1340
|
+
enum: CASE_STYLES,
|
1341
|
+
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1342
|
+
},
|
1343
|
+
asObject: {
|
1344
|
+
type: 'object',
|
1345
|
+
additionalProperties: false,
|
1346
|
+
minProperties: 1,
|
1347
|
+
properties: {
|
1348
|
+
style: { enum: CASE_STYLES },
|
1349
|
+
suffix: { type: 'string' },
|
1350
|
+
},
|
1351
|
+
},
|
1352
|
+
},
|
1353
|
+
type: 'array',
|
1354
|
+
minItems: 1,
|
1355
|
+
maxItems: 1,
|
1356
|
+
items: {
|
1357
|
+
type: 'object',
|
1358
|
+
additionalProperties: false,
|
1359
|
+
minProperties: 1,
|
1360
|
+
properties: {
|
1361
|
+
fileExtension: { enum: ['.gql', '.graphql'] },
|
1362
|
+
query: schemaOption,
|
1363
|
+
mutation: schemaOption,
|
1364
|
+
subscription: schemaOption,
|
1365
|
+
fragment: schemaOption,
|
1366
|
+
},
|
1367
|
+
},
|
1368
|
+
};
|
1369
|
+
const rule$4 = {
|
1247
1370
|
meta: {
|
1248
1371
|
type: 'suggestion',
|
1249
1372
|
docs: {
|
@@ -1334,38 +1457,7 @@ const rule$3 = {
|
|
1334
1457
|
[MATCH_EXTENSION]: 'File extension "{{ fileExtension }}" don\'t match extension "{{ expectedFileExtension }}"',
|
1335
1458
|
[MATCH_STYLE]: 'Unexpected filename "{{ filename }}". Rename it to "{{ expectedFilename }}"',
|
1336
1459
|
},
|
1337
|
-
schema:
|
1338
|
-
definitions: {
|
1339
|
-
asString: {
|
1340
|
-
enum: CASE_STYLES,
|
1341
|
-
description: `One of: ${CASE_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1342
|
-
},
|
1343
|
-
asObject: {
|
1344
|
-
type: 'object',
|
1345
|
-
additionalProperties: false,
|
1346
|
-
minProperties: 1,
|
1347
|
-
properties: {
|
1348
|
-
style: { enum: CASE_STYLES },
|
1349
|
-
suffix: { type: 'string' },
|
1350
|
-
},
|
1351
|
-
},
|
1352
|
-
},
|
1353
|
-
type: 'array',
|
1354
|
-
minItems: 1,
|
1355
|
-
maxItems: 1,
|
1356
|
-
items: {
|
1357
|
-
type: 'object',
|
1358
|
-
additionalProperties: false,
|
1359
|
-
minProperties: 1,
|
1360
|
-
properties: {
|
1361
|
-
fileExtension: { enum: ACCEPTED_EXTENSIONS },
|
1362
|
-
query: schemaOption,
|
1363
|
-
mutation: schemaOption,
|
1364
|
-
subscription: schemaOption,
|
1365
|
-
fragment: schemaOption,
|
1366
|
-
},
|
1367
|
-
},
|
1368
|
-
},
|
1460
|
+
schema: schema$4,
|
1369
1461
|
},
|
1370
1462
|
create(context) {
|
1371
1463
|
const options = context.options[0] || {
|
@@ -1467,7 +1559,67 @@ const ALLOWED_STYLES = Object.keys(StyleToRegex);
|
|
1467
1559
|
const schemaOption$1 = {
|
1468
1560
|
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
|
1469
1561
|
};
|
1470
|
-
const
|
1562
|
+
const schema$5 = {
|
1563
|
+
definitions: {
|
1564
|
+
asString: {
|
1565
|
+
enum: ALLOWED_STYLES,
|
1566
|
+
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1567
|
+
},
|
1568
|
+
asObject: {
|
1569
|
+
type: 'object',
|
1570
|
+
additionalProperties: false,
|
1571
|
+
properties: {
|
1572
|
+
style: { enum: ALLOWED_STYLES },
|
1573
|
+
prefix: { type: 'string' },
|
1574
|
+
suffix: { type: 'string' },
|
1575
|
+
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1576
|
+
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1577
|
+
ignorePattern: {
|
1578
|
+
type: 'string',
|
1579
|
+
description: 'Option to skip validation of some words, e.g. acronyms',
|
1580
|
+
},
|
1581
|
+
},
|
1582
|
+
},
|
1583
|
+
},
|
1584
|
+
type: 'array',
|
1585
|
+
maxItems: 1,
|
1586
|
+
items: {
|
1587
|
+
type: 'object',
|
1588
|
+
additionalProperties: false,
|
1589
|
+
properties: {
|
1590
|
+
types: {
|
1591
|
+
...schemaOption$1,
|
1592
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1593
|
+
},
|
1594
|
+
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1595
|
+
kind,
|
1596
|
+
{
|
1597
|
+
...schemaOption$1,
|
1598
|
+
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1599
|
+
},
|
1600
|
+
])),
|
1601
|
+
allowLeadingUnderscore: {
|
1602
|
+
type: 'boolean',
|
1603
|
+
default: false,
|
1604
|
+
},
|
1605
|
+
allowTrailingUnderscore: {
|
1606
|
+
type: 'boolean',
|
1607
|
+
default: false,
|
1608
|
+
},
|
1609
|
+
},
|
1610
|
+
patternProperties: {
|
1611
|
+
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1612
|
+
},
|
1613
|
+
description: [
|
1614
|
+
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1615
|
+
'>',
|
1616
|
+
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1617
|
+
'>',
|
1618
|
+
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1619
|
+
].join('\n'),
|
1620
|
+
},
|
1621
|
+
};
|
1622
|
+
const rule$5 = {
|
1471
1623
|
meta: {
|
1472
1624
|
type: 'suggestion',
|
1473
1625
|
docs: {
|
@@ -1583,66 +1735,7 @@ const rule$4 = {
|
|
1583
1735
|
},
|
1584
1736
|
},
|
1585
1737
|
hasSuggestions: true,
|
1586
|
-
schema:
|
1587
|
-
definitions: {
|
1588
|
-
asString: {
|
1589
|
-
enum: ALLOWED_STYLES,
|
1590
|
-
description: `One of: ${ALLOWED_STYLES.map(t => `\`${t}\``).join(', ')}`,
|
1591
|
-
},
|
1592
|
-
asObject: {
|
1593
|
-
type: 'object',
|
1594
|
-
additionalProperties: false,
|
1595
|
-
properties: {
|
1596
|
-
style: { enum: ALLOWED_STYLES },
|
1597
|
-
prefix: { type: 'string' },
|
1598
|
-
suffix: { type: 'string' },
|
1599
|
-
forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS,
|
1600
|
-
forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS,
|
1601
|
-
ignorePattern: {
|
1602
|
-
type: 'string',
|
1603
|
-
description: 'Option to skip validation of some words, e.g. acronyms',
|
1604
|
-
},
|
1605
|
-
},
|
1606
|
-
},
|
1607
|
-
},
|
1608
|
-
type: 'array',
|
1609
|
-
maxItems: 1,
|
1610
|
-
items: {
|
1611
|
-
type: 'object',
|
1612
|
-
additionalProperties: false,
|
1613
|
-
properties: {
|
1614
|
-
types: {
|
1615
|
-
...schemaOption$1,
|
1616
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
1617
|
-
},
|
1618
|
-
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
1619
|
-
kind,
|
1620
|
-
{
|
1621
|
-
...schemaOption$1,
|
1622
|
-
description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
|
1623
|
-
},
|
1624
|
-
])),
|
1625
|
-
allowLeadingUnderscore: {
|
1626
|
-
type: 'boolean',
|
1627
|
-
default: false,
|
1628
|
-
},
|
1629
|
-
allowTrailingUnderscore: {
|
1630
|
-
type: 'boolean',
|
1631
|
-
default: false,
|
1632
|
-
},
|
1633
|
-
},
|
1634
|
-
patternProperties: {
|
1635
|
-
[`^(${ALLOWED_KINDS.join('|')})(.+)?$`]: schemaOption$1,
|
1636
|
-
},
|
1637
|
-
description: [
|
1638
|
-
"> It's possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with allowed `ASTNode` names which are described below.",
|
1639
|
-
'>',
|
1640
|
-
'> Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
|
1641
|
-
'>',
|
1642
|
-
'> Example: pattern property `FieldDefinition[parent.name.value=Query]` will match only fields for type `Query`.',
|
1643
|
-
].join('\n'),
|
1644
|
-
},
|
1645
|
-
},
|
1738
|
+
schema: schema$5,
|
1646
1739
|
},
|
1647
1740
|
create(context) {
|
1648
1741
|
const options = context.options[0] || {};
|
@@ -1742,8 +1835,8 @@ const rule$4 = {
|
|
1742
1835
|
},
|
1743
1836
|
};
|
1744
1837
|
|
1745
|
-
const RULE_ID$
|
1746
|
-
const rule$
|
1838
|
+
const RULE_ID$2 = 'no-anonymous-operations';
|
1839
|
+
const rule$6 = {
|
1747
1840
|
meta: {
|
1748
1841
|
type: 'suggestion',
|
1749
1842
|
hasSuggestions: true,
|
@@ -1751,7 +1844,7 @@ const rule$5 = {
|
|
1751
1844
|
category: 'Operations',
|
1752
1845
|
description: 'Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.',
|
1753
1846
|
recommended: true,
|
1754
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1847
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
|
1755
1848
|
examples: [
|
1756
1849
|
{
|
1757
1850
|
title: 'Incorrect',
|
@@ -1772,7 +1865,7 @@ const rule$5 = {
|
|
1772
1865
|
],
|
1773
1866
|
},
|
1774
1867
|
messages: {
|
1775
|
-
[RULE_ID$
|
1868
|
+
[RULE_ID$2]: 'Anonymous GraphQL operations are forbidden. Make sure to name your {{ operation }}!',
|
1776
1869
|
},
|
1777
1870
|
schema: [],
|
1778
1871
|
},
|
@@ -1785,7 +1878,7 @@ const rule$5 = {
|
|
1785
1878
|
: node.operation;
|
1786
1879
|
context.report({
|
1787
1880
|
loc: getLocation(node.loc.start, node.operation),
|
1788
|
-
messageId: RULE_ID$
|
1881
|
+
messageId: RULE_ID$2,
|
1789
1882
|
data: {
|
1790
1883
|
operation: node.operation,
|
1791
1884
|
},
|
@@ -1805,7 +1898,7 @@ const rule$5 = {
|
|
1805
1898
|
},
|
1806
1899
|
};
|
1807
1900
|
|
1808
|
-
const rule$
|
1901
|
+
const rule$7 = {
|
1809
1902
|
meta: {
|
1810
1903
|
type: 'suggestion',
|
1811
1904
|
hasSuggestions: true,
|
@@ -1863,15 +1956,15 @@ const rule$6 = {
|
|
1863
1956
|
},
|
1864
1957
|
};
|
1865
1958
|
|
1866
|
-
const RULE_ID$
|
1867
|
-
const rule$
|
1959
|
+
const RULE_ID$3 = 'no-deprecated';
|
1960
|
+
const rule$8 = {
|
1868
1961
|
meta: {
|
1869
1962
|
type: 'suggestion',
|
1870
1963
|
hasSuggestions: true,
|
1871
1964
|
docs: {
|
1872
1965
|
category: 'Operations',
|
1873
1966
|
description: 'Enforce that deprecated fields or enum values are not in use by operations.',
|
1874
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
1967
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$3}.md`,
|
1875
1968
|
requiresSchema: true,
|
1876
1969
|
examples: [
|
1877
1970
|
{
|
@@ -1938,18 +2031,18 @@ const rule$7 = {
|
|
1938
2031
|
recommended: true,
|
1939
2032
|
},
|
1940
2033
|
messages: {
|
1941
|
-
[RULE_ID$
|
2034
|
+
[RULE_ID$3]: 'This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})',
|
1942
2035
|
},
|
1943
2036
|
schema: [],
|
1944
2037
|
},
|
1945
2038
|
create(context) {
|
1946
|
-
requireGraphQLSchemaFromContext(RULE_ID$
|
2039
|
+
requireGraphQLSchemaFromContext(RULE_ID$3, context);
|
1947
2040
|
function report(node, reason) {
|
1948
2041
|
const nodeName = node.kind === Kind.ENUM ? node.value : node.name.value;
|
1949
2042
|
const nodeType = node.kind === Kind.ENUM ? 'enum value' : 'field';
|
1950
2043
|
context.report({
|
1951
2044
|
node,
|
1952
|
-
messageId: RULE_ID$
|
2045
|
+
messageId: RULE_ID$3,
|
1953
2046
|
data: {
|
1954
2047
|
type: nodeType,
|
1955
2048
|
reason,
|
@@ -1983,15 +2076,15 @@ const rule$7 = {
|
|
1983
2076
|
},
|
1984
2077
|
};
|
1985
2078
|
|
1986
|
-
const RULE_ID$
|
1987
|
-
const rule$
|
2079
|
+
const RULE_ID$4 = 'no-duplicate-fields';
|
2080
|
+
const rule$9 = {
|
1988
2081
|
meta: {
|
1989
2082
|
type: 'suggestion',
|
1990
2083
|
hasSuggestions: true,
|
1991
2084
|
docs: {
|
1992
2085
|
description: 'Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.',
|
1993
2086
|
category: 'Operations',
|
1994
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2087
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$4}.md`,
|
1995
2088
|
recommended: true,
|
1996
2089
|
examples: [
|
1997
2090
|
{
|
@@ -2037,7 +2130,7 @@ const rule$8 = {
|
|
2037
2130
|
],
|
2038
2131
|
},
|
2039
2132
|
messages: {
|
2040
|
-
[RULE_ID$
|
2133
|
+
[RULE_ID$4]: '{{ type }} `{{ fieldName }}` defined multiple times.',
|
2041
2134
|
},
|
2042
2135
|
schema: [],
|
2043
2136
|
},
|
@@ -2048,7 +2141,7 @@ const rule$8 = {
|
|
2048
2141
|
const { parent } = node;
|
2049
2142
|
context.report({
|
2050
2143
|
node,
|
2051
|
-
messageId: RULE_ID$
|
2144
|
+
messageId: RULE_ID$4,
|
2052
2145
|
data: {
|
2053
2146
|
type: parent.type,
|
2054
2147
|
fieldName,
|
@@ -2093,7 +2186,7 @@ const rule$8 = {
|
|
2093
2186
|
};
|
2094
2187
|
|
2095
2188
|
const HASHTAG_COMMENT = 'HASHTAG_COMMENT';
|
2096
|
-
const rule$
|
2189
|
+
const rule$a = {
|
2097
2190
|
meta: {
|
2098
2191
|
type: 'suggestion',
|
2099
2192
|
hasSuggestions: true,
|
@@ -2178,8 +2271,25 @@ const rule$9 = {
|
|
2178
2271
|
},
|
2179
2272
|
};
|
2180
2273
|
|
2181
|
-
const
|
2182
|
-
|
2274
|
+
const schema$6 = {
|
2275
|
+
type: 'array',
|
2276
|
+
minItems: 1,
|
2277
|
+
maxItems: 1,
|
2278
|
+
items: {
|
2279
|
+
type: 'object',
|
2280
|
+
additionalProperties: false,
|
2281
|
+
required: ['disallow'],
|
2282
|
+
properties: {
|
2283
|
+
disallow: {
|
2284
|
+
...ARRAY_DEFAULT_OPTIONS,
|
2285
|
+
items: {
|
2286
|
+
enum: ['mutation', 'subscription'],
|
2287
|
+
},
|
2288
|
+
},
|
2289
|
+
},
|
2290
|
+
},
|
2291
|
+
};
|
2292
|
+
const rule$b = {
|
2183
2293
|
meta: {
|
2184
2294
|
type: 'suggestion',
|
2185
2295
|
hasSuggestions: true,
|
@@ -2210,24 +2320,7 @@ const rule$a = {
|
|
2210
2320
|
},
|
2211
2321
|
],
|
2212
2322
|
},
|
2213
|
-
schema:
|
2214
|
-
type: 'array',
|
2215
|
-
minItems: 1,
|
2216
|
-
maxItems: 1,
|
2217
|
-
items: {
|
2218
|
-
type: 'object',
|
2219
|
-
additionalProperties: false,
|
2220
|
-
required: ['disallow'],
|
2221
|
-
properties: {
|
2222
|
-
disallow: {
|
2223
|
-
...ARRAY_DEFAULT_OPTIONS,
|
2224
|
-
items: {
|
2225
|
-
enum: ROOT_TYPES,
|
2226
|
-
},
|
2227
|
-
},
|
2228
|
-
},
|
2229
|
-
},
|
2230
|
-
},
|
2323
|
+
schema: schema$6,
|
2231
2324
|
},
|
2232
2325
|
create(context) {
|
2233
2326
|
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
|
@@ -2261,15 +2354,15 @@ const rule$a = {
|
|
2261
2354
|
},
|
2262
2355
|
};
|
2263
2356
|
|
2264
|
-
const RULE_ID$
|
2265
|
-
const rule$
|
2357
|
+
const RULE_ID$5 = 'no-scalar-result-type-on-mutation';
|
2358
|
+
const rule$c = {
|
2266
2359
|
meta: {
|
2267
2360
|
type: 'suggestion',
|
2268
2361
|
hasSuggestions: true,
|
2269
2362
|
docs: {
|
2270
2363
|
category: 'Schema',
|
2271
2364
|
description: 'Avoid scalar result type on mutation type to make sure to return a valid state.',
|
2272
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2365
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$5}.md`,
|
2273
2366
|
requiresSchema: true,
|
2274
2367
|
examples: [
|
2275
2368
|
{
|
@@ -2293,7 +2386,7 @@ const rule$b = {
|
|
2293
2386
|
schema: [],
|
2294
2387
|
},
|
2295
2388
|
create(context) {
|
2296
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2389
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$5, context);
|
2297
2390
|
const mutationType = schema.getMutationType();
|
2298
2391
|
if (!mutationType) {
|
2299
2392
|
return {};
|
@@ -2324,7 +2417,7 @@ const rule$b = {
|
|
2324
2417
|
};
|
2325
2418
|
|
2326
2419
|
const NO_TYPENAME_PREFIX = 'NO_TYPENAME_PREFIX';
|
2327
|
-
const rule$
|
2420
|
+
const rule$d = {
|
2328
2421
|
meta: {
|
2329
2422
|
type: 'suggestion',
|
2330
2423
|
hasSuggestions: true,
|
@@ -2386,7 +2479,7 @@ const rule$c = {
|
|
2386
2479
|
},
|
2387
2480
|
};
|
2388
2481
|
|
2389
|
-
const RULE_ID$
|
2482
|
+
const RULE_ID$6 = 'no-unreachable-types';
|
2390
2483
|
const KINDS = [
|
2391
2484
|
Kind.DIRECTIVE_DEFINITION,
|
2392
2485
|
Kind.OBJECT_TYPE_DEFINITION,
|
@@ -2466,15 +2559,15 @@ function getReachableTypes(schema) {
|
|
2466
2559
|
reachableTypesCache = reachableTypes;
|
2467
2560
|
return reachableTypesCache;
|
2468
2561
|
}
|
2469
|
-
const rule$
|
2562
|
+
const rule$e = {
|
2470
2563
|
meta: {
|
2471
2564
|
messages: {
|
2472
|
-
[RULE_ID$
|
2565
|
+
[RULE_ID$6]: '{{ type }} `{{ typeName }}` is unreachable.',
|
2473
2566
|
},
|
2474
2567
|
docs: {
|
2475
2568
|
description: 'Requires all types to be reachable at some level by root level fields.',
|
2476
2569
|
category: 'Schema',
|
2477
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2570
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$6}.md`,
|
2478
2571
|
requiresSchema: true,
|
2479
2572
|
examples: [
|
2480
2573
|
{
|
@@ -2511,7 +2604,7 @@ const rule$d = {
|
|
2511
2604
|
hasSuggestions: true,
|
2512
2605
|
},
|
2513
2606
|
create(context) {
|
2514
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2607
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$6, context);
|
2515
2608
|
const reachableTypes = getReachableTypes(schema);
|
2516
2609
|
return {
|
2517
2610
|
[`:matches(${KINDS}) > .name`](node) {
|
@@ -2520,7 +2613,7 @@ const rule$d = {
|
|
2520
2613
|
const type = lowerCase(node.parent.kind.replace(/(Extension|Definition)$/, ''));
|
2521
2614
|
context.report({
|
2522
2615
|
node,
|
2523
|
-
messageId: RULE_ID$
|
2616
|
+
messageId: RULE_ID$6,
|
2524
2617
|
data: {
|
2525
2618
|
type: type[0].toUpperCase() + type.slice(1),
|
2526
2619
|
typeName,
|
@@ -2538,7 +2631,7 @@ const rule$d = {
|
|
2538
2631
|
},
|
2539
2632
|
};
|
2540
2633
|
|
2541
|
-
const RULE_ID$
|
2634
|
+
const RULE_ID$7 = 'no-unused-fields';
|
2542
2635
|
let usedFieldsCache;
|
2543
2636
|
function getUsedFields(schema, operations) {
|
2544
2637
|
// We don't want cache usedFields on test environment
|
@@ -2569,15 +2662,15 @@ function getUsedFields(schema, operations) {
|
|
2569
2662
|
usedFieldsCache = usedFields;
|
2570
2663
|
return usedFieldsCache;
|
2571
2664
|
}
|
2572
|
-
const rule$
|
2665
|
+
const rule$f = {
|
2573
2666
|
meta: {
|
2574
2667
|
messages: {
|
2575
|
-
[RULE_ID$
|
2668
|
+
[RULE_ID$7]: 'Field "{{fieldName}}" is unused',
|
2576
2669
|
},
|
2577
2670
|
docs: {
|
2578
2671
|
description: 'Requires all fields to be used at some level by siblings operations.',
|
2579
2672
|
category: 'Schema',
|
2580
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2673
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$7}.md`,
|
2581
2674
|
requiresSiblings: true,
|
2582
2675
|
requiresSchema: true,
|
2583
2676
|
isDisabledForAllConfig: true,
|
@@ -2630,8 +2723,8 @@ const rule$e = {
|
|
2630
2723
|
hasSuggestions: true,
|
2631
2724
|
},
|
2632
2725
|
create(context) {
|
2633
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2634
|
-
const siblingsOperations = requireSiblingsOperations(RULE_ID$
|
2726
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$7, context);
|
2727
|
+
const siblingsOperations = requireSiblingsOperations(RULE_ID$7, context);
|
2635
2728
|
const usedFields = getUsedFields(schema, siblingsOperations);
|
2636
2729
|
return {
|
2637
2730
|
FieldDefinition(node) {
|
@@ -2644,7 +2737,7 @@ const rule$e = {
|
|
2644
2737
|
}
|
2645
2738
|
context.report({
|
2646
2739
|
node: node.name,
|
2647
|
-
messageId: RULE_ID$
|
2740
|
+
messageId: RULE_ID$7,
|
2648
2741
|
data: { fieldName },
|
2649
2742
|
suggest: [
|
2650
2743
|
{
|
@@ -2664,9 +2757,25 @@ const rule$e = {
|
|
2664
2757
|
},
|
2665
2758
|
};
|
2666
2759
|
|
2667
|
-
const RULE_ID$
|
2760
|
+
const RULE_ID$8 = 'relay-arguments';
|
2668
2761
|
const MISSING_ARGUMENTS = 'MISSING_ARGUMENTS';
|
2669
|
-
const
|
2762
|
+
const schema$7 = {
|
2763
|
+
type: 'array',
|
2764
|
+
maxItems: 1,
|
2765
|
+
items: {
|
2766
|
+
type: 'object',
|
2767
|
+
additionalProperties: false,
|
2768
|
+
minProperties: 1,
|
2769
|
+
properties: {
|
2770
|
+
includeBoth: {
|
2771
|
+
type: 'boolean',
|
2772
|
+
default: true,
|
2773
|
+
description: 'Enforce including both forward and backward pagination arguments',
|
2774
|
+
},
|
2775
|
+
},
|
2776
|
+
},
|
2777
|
+
};
|
2778
|
+
const rule$g = {
|
2670
2779
|
meta: {
|
2671
2780
|
type: 'problem',
|
2672
2781
|
docs: {
|
@@ -2686,7 +2795,7 @@ const rule$f = {
|
|
2686
2795
|
'- `last` takes a non-negative integer',
|
2687
2796
|
'- `before` takes the Cursor type',
|
2688
2797
|
].join('\n'),
|
2689
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
2798
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$8}.md`,
|
2690
2799
|
examples: [
|
2691
2800
|
{
|
2692
2801
|
title: 'Incorrect',
|
@@ -2710,25 +2819,10 @@ const rule$f = {
|
|
2710
2819
|
messages: {
|
2711
2820
|
[MISSING_ARGUMENTS]: 'A field that returns a Connection type must include forward pagination arguments (`first` and `after`), backward pagination arguments (`last` and `before`), or both.',
|
2712
2821
|
},
|
2713
|
-
schema:
|
2714
|
-
type: 'array',
|
2715
|
-
maxItems: 1,
|
2716
|
-
items: {
|
2717
|
-
type: 'object',
|
2718
|
-
additionalProperties: false,
|
2719
|
-
minProperties: 1,
|
2720
|
-
properties: {
|
2721
|
-
includeBoth: {
|
2722
|
-
type: 'boolean',
|
2723
|
-
default: true,
|
2724
|
-
description: 'Enforce including both forward and backward pagination arguments',
|
2725
|
-
},
|
2726
|
-
},
|
2727
|
-
},
|
2728
|
-
},
|
2822
|
+
schema: schema$7,
|
2729
2823
|
},
|
2730
2824
|
create(context) {
|
2731
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
2825
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$8, context);
|
2732
2826
|
const { includeBoth = true } = context.options[0] || {};
|
2733
2827
|
return {
|
2734
2828
|
'FieldDefinition > .gqlType Name[value=/Connection$/]'(node) {
|
@@ -2800,7 +2894,7 @@ const NON_OBJECT_TYPES = [
|
|
2800
2894
|
const notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`;
|
2801
2895
|
const hasEdgesField = (node) => node.fields.some(field => field.name.value === 'edges');
|
2802
2896
|
const hasPageInfoField = (node) => node.fields.some(field => field.name.value === 'pageInfo');
|
2803
|
-
const rule$
|
2897
|
+
const rule$h = {
|
2804
2898
|
meta: {
|
2805
2899
|
type: 'problem',
|
2806
2900
|
docs: {
|
@@ -2884,7 +2978,7 @@ const rule$g = {
|
|
2884
2978
|
},
|
2885
2979
|
};
|
2886
2980
|
|
2887
|
-
const RULE_ID$
|
2981
|
+
const RULE_ID$9 = 'relay-edge-types';
|
2888
2982
|
const MESSAGE_MUST_BE_OBJECT_TYPE = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
2889
2983
|
const MESSAGE_MISSING_EDGE_SUFFIX = 'MESSAGE_MISSING_EDGE_SUFFIX';
|
2890
2984
|
const MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE = 'MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE';
|
@@ -2919,7 +3013,33 @@ function getEdgeTypes(schema) {
|
|
2919
3013
|
edgeTypesCache = edgeTypes;
|
2920
3014
|
return edgeTypesCache;
|
2921
3015
|
}
|
2922
|
-
const
|
3016
|
+
const schema$8 = {
|
3017
|
+
type: 'array',
|
3018
|
+
maxItems: 1,
|
3019
|
+
items: {
|
3020
|
+
type: 'object',
|
3021
|
+
additionalProperties: false,
|
3022
|
+
minProperties: 1,
|
3023
|
+
properties: {
|
3024
|
+
withEdgeSuffix: {
|
3025
|
+
type: 'boolean',
|
3026
|
+
default: true,
|
3027
|
+
description: 'Edge type name must end in "Edge".',
|
3028
|
+
},
|
3029
|
+
shouldImplementNode: {
|
3030
|
+
type: 'boolean',
|
3031
|
+
default: true,
|
3032
|
+
description: "Edge type's field `node` must implement `Node` interface.",
|
3033
|
+
},
|
3034
|
+
listTypeCanWrapOnlyEdgeType: {
|
3035
|
+
type: 'boolean',
|
3036
|
+
default: true,
|
3037
|
+
description: 'A list type should only wrap an edge type.',
|
3038
|
+
},
|
3039
|
+
},
|
3040
|
+
},
|
3041
|
+
};
|
3042
|
+
const rule$i = {
|
2923
3043
|
meta: {
|
2924
3044
|
type: 'problem',
|
2925
3045
|
docs: {
|
@@ -2935,7 +3055,7 @@ const rule$h = {
|
|
2935
3055
|
"- Edge type's field `node` must implement `Node` interface _(optional)_",
|
2936
3056
|
'- A list type should only wrap an edge type _(optional)_',
|
2937
3057
|
].join('\n'),
|
2938
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3058
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$9}.md`,
|
2939
3059
|
isDisabledForAllConfig: true,
|
2940
3060
|
requiresSchema: true,
|
2941
3061
|
examples: [
|
@@ -2956,35 +3076,10 @@ const rule$h = {
|
|
2956
3076
|
[MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE]: 'A list type should only wrap an edge type.',
|
2957
3077
|
[MESSAGE_SHOULD_IMPLEMENTS_NODE]: "Edge type's field `node` must implement `Node` interface.",
|
2958
3078
|
},
|
2959
|
-
schema:
|
2960
|
-
type: 'array',
|
2961
|
-
maxItems: 1,
|
2962
|
-
items: {
|
2963
|
-
type: 'object',
|
2964
|
-
additionalProperties: false,
|
2965
|
-
minProperties: 1,
|
2966
|
-
properties: {
|
2967
|
-
withEdgeSuffix: {
|
2968
|
-
type: 'boolean',
|
2969
|
-
default: true,
|
2970
|
-
description: 'Edge type name must end in "Edge".',
|
2971
|
-
},
|
2972
|
-
shouldImplementNode: {
|
2973
|
-
type: 'boolean',
|
2974
|
-
default: true,
|
2975
|
-
description: "Edge type's field `node` must implement `Node` interface.",
|
2976
|
-
},
|
2977
|
-
listTypeCanWrapOnlyEdgeType: {
|
2978
|
-
type: 'boolean',
|
2979
|
-
default: true,
|
2980
|
-
description: 'A list type should only wrap an edge type.',
|
2981
|
-
},
|
2982
|
-
},
|
2983
|
-
},
|
2984
|
-
},
|
3079
|
+
schema: schema$8,
|
2985
3080
|
},
|
2986
3081
|
create(context) {
|
2987
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3082
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$9, context);
|
2988
3083
|
const edgeTypes = getEdgeTypes(schema);
|
2989
3084
|
const options = {
|
2990
3085
|
withEdgeSuffix: true,
|
@@ -3067,12 +3162,12 @@ const rule$h = {
|
|
3067
3162
|
},
|
3068
3163
|
};
|
3069
3164
|
|
3070
|
-
const RULE_ID$
|
3165
|
+
const RULE_ID$a = 'relay-page-info';
|
3071
3166
|
const MESSAGE_MUST_EXIST = 'MESSAGE_MUST_EXIST';
|
3072
3167
|
const MESSAGE_MUST_BE_OBJECT_TYPE$1 = 'MESSAGE_MUST_BE_OBJECT_TYPE';
|
3073
3168
|
const notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`;
|
3074
3169
|
let hasPageInfoChecked = false;
|
3075
|
-
const rule$
|
3170
|
+
const rule$j = {
|
3076
3171
|
meta: {
|
3077
3172
|
type: 'problem',
|
3078
3173
|
docs: {
|
@@ -3084,7 +3179,7 @@ const rule$i = {
|
|
3084
3179
|
'- `PageInfo` must contain fields `hasPreviousPage` and `hasNextPage`, that return non-null Boolean',
|
3085
3180
|
'- `PageInfo` must contain fields `startCursor` and `endCursor`, that return either String or Scalar, which can be null if there are no results',
|
3086
3181
|
].join('\n'),
|
3087
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3182
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$a}.md`,
|
3088
3183
|
examples: [
|
3089
3184
|
{
|
3090
3185
|
title: 'Correct',
|
@@ -3108,7 +3203,7 @@ const rule$i = {
|
|
3108
3203
|
schema: [],
|
3109
3204
|
},
|
3110
3205
|
create(context) {
|
3111
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3206
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$a, context);
|
3112
3207
|
if (process.env.NODE_ENV === 'test' || !hasPageInfoChecked) {
|
3113
3208
|
const pageInfoType = schema.getType('PageInfo');
|
3114
3209
|
if (!pageInfoType) {
|
@@ -3324,7 +3419,20 @@ const MESSAGE_REQUIRE_DATE = 'MESSAGE_REQUIRE_DATE';
|
|
3324
3419
|
const MESSAGE_INVALID_FORMAT = 'MESSAGE_INVALID_FORMAT';
|
3325
3420
|
const MESSAGE_INVALID_DATE = 'MESSAGE_INVALID_DATE';
|
3326
3421
|
const MESSAGE_CAN_BE_REMOVED = 'MESSAGE_CAN_BE_REMOVED';
|
3327
|
-
const
|
3422
|
+
const schema$9 = {
|
3423
|
+
type: 'array',
|
3424
|
+
maxItems: 1,
|
3425
|
+
items: {
|
3426
|
+
type: 'object',
|
3427
|
+
additionalProperties: false,
|
3428
|
+
properties: {
|
3429
|
+
argumentName: {
|
3430
|
+
type: 'string',
|
3431
|
+
},
|
3432
|
+
},
|
3433
|
+
},
|
3434
|
+
};
|
3435
|
+
const rule$k = {
|
3328
3436
|
meta: {
|
3329
3437
|
type: 'suggestion',
|
3330
3438
|
hasSuggestions: true,
|
@@ -3369,17 +3477,7 @@ const rule$j = {
|
|
3369
3477
|
[MESSAGE_INVALID_DATE]: 'Invalid "{{ deletionDate }}" deletion date',
|
3370
3478
|
[MESSAGE_CAN_BE_REMOVED]: '"{{ nodeName }}" сan be removed',
|
3371
3479
|
},
|
3372
|
-
schema:
|
3373
|
-
{
|
3374
|
-
type: 'object',
|
3375
|
-
additionalProperties: false,
|
3376
|
-
properties: {
|
3377
|
-
argumentName: {
|
3378
|
-
type: 'string',
|
3379
|
-
},
|
3380
|
-
},
|
3381
|
-
},
|
3382
|
-
],
|
3480
|
+
schema: schema$9,
|
3383
3481
|
},
|
3384
3482
|
create(context) {
|
3385
3483
|
return {
|
@@ -3435,7 +3533,7 @@ const rule$j = {
|
|
3435
3533
|
},
|
3436
3534
|
};
|
3437
3535
|
|
3438
|
-
const rule$
|
3536
|
+
const rule$l = {
|
3439
3537
|
meta: {
|
3440
3538
|
docs: {
|
3441
3539
|
description: 'Require all deprecation directives to specify a reason.',
|
@@ -3488,7 +3586,7 @@ const rule$k = {
|
|
3488
3586
|
},
|
3489
3587
|
};
|
3490
3588
|
|
3491
|
-
const RULE_ID$
|
3589
|
+
const RULE_ID$b = 'require-description';
|
3492
3590
|
const ALLOWED_KINDS$1 = [
|
3493
3591
|
...TYPES_KINDS,
|
3494
3592
|
Kind.DIRECTIVE_DEFINITION,
|
@@ -3525,12 +3623,40 @@ function getNodeName(node) {
|
|
3525
3623
|
return node.name ? `${node.operation} ${node.name.value}` : node.operation;
|
3526
3624
|
}
|
3527
3625
|
}
|
3528
|
-
const
|
3626
|
+
const schema$a = {
|
3627
|
+
type: 'array',
|
3628
|
+
minItems: 1,
|
3629
|
+
maxItems: 1,
|
3630
|
+
items: {
|
3631
|
+
type: 'object',
|
3632
|
+
additionalProperties: false,
|
3633
|
+
minProperties: 1,
|
3634
|
+
properties: {
|
3635
|
+
types: {
|
3636
|
+
type: 'boolean',
|
3637
|
+
description: `Includes:\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3638
|
+
},
|
3639
|
+
rootField: {
|
3640
|
+
type: 'boolean',
|
3641
|
+
description: 'Definitions within `Query`, `Mutation`, and `Subscription` root types.',
|
3642
|
+
},
|
3643
|
+
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3644
|
+
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3645
|
+
if (kind === Kind.OPERATION_DEFINITION) {
|
3646
|
+
description +=
|
3647
|
+
'\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3648
|
+
}
|
3649
|
+
return [kind, { type: 'boolean', description }];
|
3650
|
+
})),
|
3651
|
+
},
|
3652
|
+
},
|
3653
|
+
};
|
3654
|
+
const rule$m = {
|
3529
3655
|
meta: {
|
3530
3656
|
docs: {
|
3531
3657
|
category: 'Schema',
|
3532
3658
|
description: 'Enforce descriptions in type definitions and operations.',
|
3533
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3659
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$b}.md`,
|
3534
3660
|
examples: [
|
3535
3661
|
{
|
3536
3662
|
title: 'Incorrect',
|
@@ -3564,6 +3690,20 @@ const rule$l = {
|
|
3564
3690
|
mutation createUser {
|
3565
3691
|
# ...
|
3566
3692
|
}
|
3693
|
+
`,
|
3694
|
+
},
|
3695
|
+
{
|
3696
|
+
title: 'Correct',
|
3697
|
+
usage: [{ rootField: true }],
|
3698
|
+
code: /* GraphQL */ `
|
3699
|
+
type Mutation {
|
3700
|
+
"Create a new user"
|
3701
|
+
createUser: User
|
3702
|
+
}
|
3703
|
+
|
3704
|
+
type User {
|
3705
|
+
name: String
|
3706
|
+
}
|
3567
3707
|
`,
|
3568
3708
|
},
|
3569
3709
|
],
|
@@ -3571,41 +3711,19 @@ const rule$l = {
|
|
3571
3711
|
{
|
3572
3712
|
types: true,
|
3573
3713
|
[Kind.DIRECTIVE_DEFINITION]: true,
|
3714
|
+
// rootField: true TODO enable in graphql-eslint v4
|
3574
3715
|
},
|
3575
3716
|
],
|
3576
3717
|
recommended: true,
|
3577
3718
|
},
|
3578
3719
|
type: 'suggestion',
|
3579
3720
|
messages: {
|
3580
|
-
[RULE_ID$
|
3581
|
-
},
|
3582
|
-
schema: {
|
3583
|
-
type: 'array',
|
3584
|
-
minItems: 1,
|
3585
|
-
maxItems: 1,
|
3586
|
-
items: {
|
3587
|
-
type: 'object',
|
3588
|
-
additionalProperties: false,
|
3589
|
-
minProperties: 1,
|
3590
|
-
properties: {
|
3591
|
-
types: {
|
3592
|
-
type: 'boolean',
|
3593
|
-
description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
3594
|
-
},
|
3595
|
-
...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
|
3596
|
-
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
3597
|
-
if (kind === Kind.OPERATION_DEFINITION) {
|
3598
|
-
description +=
|
3599
|
-
'\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
|
3600
|
-
}
|
3601
|
-
return [kind, { type: 'boolean', description }];
|
3602
|
-
})),
|
3603
|
-
},
|
3604
|
-
},
|
3721
|
+
[RULE_ID$b]: 'Description is required for `{{ nodeName }}`.',
|
3605
3722
|
},
|
3723
|
+
schema: schema$a,
|
3606
3724
|
},
|
3607
3725
|
create(context) {
|
3608
|
-
const { types, ...restOptions } = context.options[0] || {};
|
3726
|
+
const { types, rootField, ...restOptions } = context.options[0] || {};
|
3609
3727
|
const kinds = new Set(types ? TYPES_KINDS : []);
|
3610
3728
|
for (const [kind, isEnabled] of Object.entries(restOptions)) {
|
3611
3729
|
if (isEnabled) {
|
@@ -3615,6 +3733,13 @@ const rule$l = {
|
|
3615
3733
|
kinds.delete(kind);
|
3616
3734
|
}
|
3617
3735
|
}
|
3736
|
+
if (rootField) {
|
3737
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$b, context);
|
3738
|
+
const rootTypeNames = getRootTypeNames(schema);
|
3739
|
+
kinds.add(`:matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/^(${[
|
3740
|
+
...rootTypeNames,
|
3741
|
+
].join(',')})$/] > FieldDefinition`);
|
3742
|
+
}
|
3618
3743
|
const selector = [...kinds].join(',');
|
3619
3744
|
return {
|
3620
3745
|
[selector](node) {
|
@@ -3638,7 +3763,7 @@ const rule$l = {
|
|
3638
3763
|
if (description.length === 0) {
|
3639
3764
|
context.report({
|
3640
3765
|
loc: isOperation ? getLocation(node.loc.start, node.operation) : node.name.loc,
|
3641
|
-
messageId: RULE_ID$
|
3766
|
+
messageId: RULE_ID$b,
|
3642
3767
|
data: {
|
3643
3768
|
nodeName: getNodeName(node),
|
3644
3769
|
},
|
@@ -3649,14 +3774,14 @@ const rule$l = {
|
|
3649
3774
|
},
|
3650
3775
|
};
|
3651
3776
|
|
3652
|
-
const RULE_ID$
|
3653
|
-
const rule$
|
3777
|
+
const RULE_ID$c = 'require-field-of-type-query-in-mutation-result';
|
3778
|
+
const rule$n = {
|
3654
3779
|
meta: {
|
3655
3780
|
type: 'suggestion',
|
3656
3781
|
docs: {
|
3657
3782
|
category: 'Schema',
|
3658
3783
|
description: 'Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.\n> Currently, no errors are reported for result type `union`, `interface` and `scalar`.',
|
3659
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3784
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$c}.md`,
|
3660
3785
|
requiresSchema: true,
|
3661
3786
|
examples: [
|
3662
3787
|
{
|
@@ -3691,7 +3816,7 @@ const rule$m = {
|
|
3691
3816
|
schema: [],
|
3692
3817
|
},
|
3693
3818
|
create(context) {
|
3694
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3819
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$c, context);
|
3695
3820
|
const mutationType = schema.getMutationType();
|
3696
3821
|
const queryType = schema.getQueryType();
|
3697
3822
|
if (!mutationType || !queryType) {
|
@@ -3717,17 +3842,36 @@ const rule$m = {
|
|
3717
3842
|
},
|
3718
3843
|
};
|
3719
3844
|
|
3720
|
-
const RULE_ID$
|
3845
|
+
const RULE_ID$d = 'require-id-when-available';
|
3721
3846
|
const DEFAULT_ID_FIELD_NAME = 'id';
|
3722
|
-
const
|
3847
|
+
const schema$b = {
|
3848
|
+
definitions: {
|
3849
|
+
asString: {
|
3850
|
+
type: 'string',
|
3851
|
+
},
|
3852
|
+
asArray: ARRAY_DEFAULT_OPTIONS,
|
3853
|
+
},
|
3854
|
+
type: 'array',
|
3855
|
+
maxItems: 1,
|
3856
|
+
items: {
|
3857
|
+
type: 'object',
|
3858
|
+
additionalProperties: false,
|
3859
|
+
properties: {
|
3860
|
+
fieldName: {
|
3861
|
+
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3862
|
+
default: DEFAULT_ID_FIELD_NAME,
|
3863
|
+
},
|
3864
|
+
},
|
3865
|
+
},
|
3866
|
+
};
|
3867
|
+
const rule$o = {
|
3723
3868
|
meta: {
|
3724
3869
|
type: 'suggestion',
|
3725
|
-
// eslint-disable-next-line eslint-plugin/require-meta-has-suggestions
|
3726
3870
|
hasSuggestions: true,
|
3727
3871
|
docs: {
|
3728
3872
|
category: 'Operations',
|
3729
3873
|
description: 'Enforce selecting specific fields when they are available on the GraphQL type.',
|
3730
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
3874
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$d}.md`,
|
3731
3875
|
requiresSchema: true,
|
3732
3876
|
requiresSiblings: true,
|
3733
3877
|
examples: [
|
@@ -3777,32 +3921,13 @@ const rule$n = {
|
|
3777
3921
|
recommended: true,
|
3778
3922
|
},
|
3779
3923
|
messages: {
|
3780
|
-
[RULE_ID$
|
3781
|
-
},
|
3782
|
-
schema: {
|
3783
|
-
definitions: {
|
3784
|
-
asString: {
|
3785
|
-
type: 'string',
|
3786
|
-
},
|
3787
|
-
asArray: ARRAY_DEFAULT_OPTIONS,
|
3788
|
-
},
|
3789
|
-
type: 'array',
|
3790
|
-
maxItems: 1,
|
3791
|
-
items: {
|
3792
|
-
type: 'object',
|
3793
|
-
additionalProperties: false,
|
3794
|
-
properties: {
|
3795
|
-
fieldName: {
|
3796
|
-
oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asArray' }],
|
3797
|
-
default: DEFAULT_ID_FIELD_NAME,
|
3798
|
-
},
|
3799
|
-
},
|
3800
|
-
},
|
3924
|
+
[RULE_ID$d]: "Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.\nInclude it in your selection set{{ addition }}.",
|
3801
3925
|
},
|
3926
|
+
schema: schema$b,
|
3802
3927
|
},
|
3803
3928
|
create(context) {
|
3804
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
3805
|
-
const siblings = requireSiblingsOperations(RULE_ID$
|
3929
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$d, context);
|
3930
|
+
const siblings = requireSiblingsOperations(RULE_ID$d, context);
|
3806
3931
|
const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};
|
3807
3932
|
const idNames = asArray(fieldName);
|
3808
3933
|
// Check selections only in OperationDefinition,
|
@@ -3883,7 +4008,7 @@ const rule$n = {
|
|
3883
4008
|
: ` or add to used fragment${checkedFragmentSpreads.size > 1 ? 's' : ''} ${englishJoinWords([...checkedFragmentSpreads].map(name => `\`${name}\``))}`;
|
3884
4009
|
const problem = {
|
3885
4010
|
loc,
|
3886
|
-
messageId: RULE_ID$
|
4011
|
+
messageId: RULE_ID$d,
|
3887
4012
|
data: {
|
3888
4013
|
pluralSuffix,
|
3889
4014
|
fieldName,
|
@@ -3910,15 +4035,31 @@ const rule$n = {
|
|
3910
4035
|
},
|
3911
4036
|
};
|
3912
4037
|
|
3913
|
-
const RULE_ID$
|
3914
|
-
const
|
4038
|
+
const RULE_ID$e = 'selection-set-depth';
|
4039
|
+
const schema$c = {
|
4040
|
+
type: 'array',
|
4041
|
+
minItems: 1,
|
4042
|
+
maxItems: 1,
|
4043
|
+
items: {
|
4044
|
+
type: 'object',
|
4045
|
+
additionalProperties: false,
|
4046
|
+
required: ['maxDepth'],
|
4047
|
+
properties: {
|
4048
|
+
maxDepth: {
|
4049
|
+
type: 'number',
|
4050
|
+
},
|
4051
|
+
ignore: ARRAY_DEFAULT_OPTIONS,
|
4052
|
+
},
|
4053
|
+
},
|
4054
|
+
};
|
4055
|
+
const rule$p = {
|
3915
4056
|
meta: {
|
3916
4057
|
type: 'suggestion',
|
3917
4058
|
hasSuggestions: true,
|
3918
4059
|
docs: {
|
3919
4060
|
category: 'Operations',
|
3920
4061
|
description: 'Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).',
|
3921
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4062
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$e}.md`,
|
3922
4063
|
requiresSiblings: true,
|
3923
4064
|
examples: [
|
3924
4065
|
{
|
@@ -3964,30 +4105,15 @@ const rule$o = {
|
|
3964
4105
|
recommended: true,
|
3965
4106
|
configOptions: [{ maxDepth: 7 }],
|
3966
4107
|
},
|
3967
|
-
schema:
|
3968
|
-
type: 'array',
|
3969
|
-
minItems: 1,
|
3970
|
-
maxItems: 1,
|
3971
|
-
items: {
|
3972
|
-
type: 'object',
|
3973
|
-
additionalProperties: false,
|
3974
|
-
required: ['maxDepth'],
|
3975
|
-
properties: {
|
3976
|
-
maxDepth: {
|
3977
|
-
type: 'number',
|
3978
|
-
},
|
3979
|
-
ignore: ARRAY_DEFAULT_OPTIONS,
|
3980
|
-
},
|
3981
|
-
},
|
3982
|
-
},
|
4108
|
+
schema: schema$c,
|
3983
4109
|
},
|
3984
4110
|
create(context) {
|
3985
4111
|
let siblings = null;
|
3986
4112
|
try {
|
3987
|
-
siblings = requireSiblingsOperations(RULE_ID$
|
4113
|
+
siblings = requireSiblingsOperations(RULE_ID$e, context);
|
3988
4114
|
}
|
3989
4115
|
catch (_a) {
|
3990
|
-
logger.warn(`Rule "${RULE_ID$
|
4116
|
+
logger.warn(`Rule "${RULE_ID$e}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`);
|
3991
4117
|
}
|
3992
4118
|
const { maxDepth, ignore = [] } = context.options[0];
|
3993
4119
|
const checkFn = depthLimit(maxDepth, { ignore });
|
@@ -4031,22 +4157,54 @@ const rule$o = {
|
|
4031
4157
|
});
|
4032
4158
|
}
|
4033
4159
|
catch (e) {
|
4034
|
-
logger.warn(`Rule "${RULE_ID$
|
4160
|
+
logger.warn(`Rule "${RULE_ID$e}" check failed due to a missing siblings operations. For more info: https://bit.ly/graphql-eslint-operations`, e);
|
4035
4161
|
}
|
4036
4162
|
},
|
4037
4163
|
};
|
4038
4164
|
},
|
4039
4165
|
};
|
4040
4166
|
|
4041
|
-
const RULE_ID$
|
4042
|
-
const
|
4167
|
+
const RULE_ID$f = 'strict-id-in-types';
|
4168
|
+
const schema$d = {
|
4169
|
+
type: 'array',
|
4170
|
+
maxItems: 1,
|
4171
|
+
items: {
|
4172
|
+
type: 'object',
|
4173
|
+
additionalProperties: false,
|
4174
|
+
properties: {
|
4175
|
+
acceptedIdNames: {
|
4176
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4177
|
+
default: ['id'],
|
4178
|
+
},
|
4179
|
+
acceptedIdTypes: {
|
4180
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4181
|
+
default: ['ID'],
|
4182
|
+
},
|
4183
|
+
exceptions: {
|
4184
|
+
type: 'object',
|
4185
|
+
additionalProperties: false,
|
4186
|
+
properties: {
|
4187
|
+
types: {
|
4188
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4189
|
+
description: 'This is used to exclude types with names that match one of the specified values.',
|
4190
|
+
},
|
4191
|
+
suffixes: {
|
4192
|
+
...ARRAY_DEFAULT_OPTIONS,
|
4193
|
+
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4194
|
+
},
|
4195
|
+
},
|
4196
|
+
},
|
4197
|
+
},
|
4198
|
+
},
|
4199
|
+
};
|
4200
|
+
const rule$q = {
|
4043
4201
|
meta: {
|
4044
4202
|
type: 'suggestion',
|
4045
4203
|
docs: {
|
4046
4204
|
description: 'Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.',
|
4047
4205
|
category: 'Schema',
|
4048
4206
|
recommended: true,
|
4049
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4207
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$f}.md`,
|
4050
4208
|
requiresSchema: true,
|
4051
4209
|
examples: [
|
4052
4210
|
{
|
@@ -4110,37 +4268,7 @@ const rule$p = {
|
|
4110
4268
|
},
|
4111
4269
|
],
|
4112
4270
|
},
|
4113
|
-
schema:
|
4114
|
-
type: 'array',
|
4115
|
-
maxItems: 1,
|
4116
|
-
items: {
|
4117
|
-
type: 'object',
|
4118
|
-
additionalProperties: false,
|
4119
|
-
properties: {
|
4120
|
-
acceptedIdNames: {
|
4121
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4122
|
-
default: ['id'],
|
4123
|
-
},
|
4124
|
-
acceptedIdTypes: {
|
4125
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4126
|
-
default: ['ID'],
|
4127
|
-
},
|
4128
|
-
exceptions: {
|
4129
|
-
type: 'object',
|
4130
|
-
properties: {
|
4131
|
-
types: {
|
4132
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4133
|
-
description: 'This is used to exclude types with names that match one of the specified values.',
|
4134
|
-
},
|
4135
|
-
suffixes: {
|
4136
|
-
...ARRAY_DEFAULT_OPTIONS,
|
4137
|
-
description: 'This is used to exclude types with names with suffixes that match one of the specified values.',
|
4138
|
-
},
|
4139
|
-
},
|
4140
|
-
},
|
4141
|
-
},
|
4142
|
-
},
|
4143
|
-
},
|
4271
|
+
schema: schema$d,
|
4144
4272
|
},
|
4145
4273
|
create(context) {
|
4146
4274
|
const options = {
|
@@ -4149,7 +4277,7 @@ const rule$p = {
|
|
4149
4277
|
exceptions: {},
|
4150
4278
|
...context.options[0],
|
4151
4279
|
};
|
4152
|
-
const schema = requireGraphQLSchemaFromContext(RULE_ID$
|
4280
|
+
const schema = requireGraphQLSchemaFromContext(RULE_ID$f, context);
|
4153
4281
|
const rootTypeNames = [
|
4154
4282
|
schema.getQueryType(),
|
4155
4283
|
schema.getMutationType(),
|
@@ -4194,7 +4322,7 @@ const rule$p = {
|
|
4194
4322
|
},
|
4195
4323
|
};
|
4196
4324
|
|
4197
|
-
const RULE_ID$
|
4325
|
+
const RULE_ID$g = 'unique-fragment-name';
|
4198
4326
|
const checkNode = (context, node, ruleId) => {
|
4199
4327
|
const documentName = node.name.value;
|
4200
4328
|
const siblings = requireSiblingsOperations(ruleId, context);
|
@@ -4221,13 +4349,13 @@ const checkNode = (context, node, ruleId) => {
|
|
4221
4349
|
});
|
4222
4350
|
}
|
4223
4351
|
};
|
4224
|
-
const rule$
|
4352
|
+
const rule$r = {
|
4225
4353
|
meta: {
|
4226
4354
|
type: 'suggestion',
|
4227
4355
|
docs: {
|
4228
4356
|
category: 'Operations',
|
4229
4357
|
description: 'Enforce unique fragment names across your project.',
|
4230
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4358
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$g}.md`,
|
4231
4359
|
requiresSiblings: true,
|
4232
4360
|
examples: [
|
4233
4361
|
{
|
@@ -4265,27 +4393,27 @@ const rule$q = {
|
|
4265
4393
|
],
|
4266
4394
|
},
|
4267
4395
|
messages: {
|
4268
|
-
[RULE_ID$
|
4396
|
+
[RULE_ID$g]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4269
4397
|
},
|
4270
4398
|
schema: [],
|
4271
4399
|
},
|
4272
4400
|
create(context) {
|
4273
4401
|
return {
|
4274
4402
|
FragmentDefinition(node) {
|
4275
|
-
checkNode(context, node, RULE_ID$
|
4403
|
+
checkNode(context, node, RULE_ID$g);
|
4276
4404
|
},
|
4277
4405
|
};
|
4278
4406
|
},
|
4279
4407
|
};
|
4280
4408
|
|
4281
|
-
const RULE_ID$
|
4282
|
-
const rule$
|
4409
|
+
const RULE_ID$h = 'unique-operation-name';
|
4410
|
+
const rule$s = {
|
4283
4411
|
meta: {
|
4284
4412
|
type: 'suggestion',
|
4285
4413
|
docs: {
|
4286
4414
|
category: 'Operations',
|
4287
4415
|
description: 'Enforce unique operation names across your project.',
|
4288
|
-
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$
|
4416
|
+
url: `https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/${RULE_ID$h}.md`,
|
4289
4417
|
requiresSiblings: true,
|
4290
4418
|
examples: [
|
4291
4419
|
{
|
@@ -4327,14 +4455,14 @@ const rule$r = {
|
|
4327
4455
|
],
|
4328
4456
|
},
|
4329
4457
|
messages: {
|
4330
|
-
[RULE_ID$
|
4458
|
+
[RULE_ID$h]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
|
4331
4459
|
},
|
4332
4460
|
schema: [],
|
4333
4461
|
},
|
4334
4462
|
create(context) {
|
4335
4463
|
return {
|
4336
4464
|
'OperationDefinition[name!=undefined]'(node) {
|
4337
|
-
checkNode(context, node, RULE_ID$
|
4465
|
+
checkNode(context, node, RULE_ID$h);
|
4338
4466
|
},
|
4339
4467
|
};
|
4340
4468
|
},
|
@@ -4348,31 +4476,32 @@ const rules = {
|
|
4348
4476
|
alphabetize: rule,
|
4349
4477
|
'description-style': rule$1,
|
4350
4478
|
'input-name': rule$2,
|
4351
|
-
'
|
4352
|
-
'
|
4353
|
-
'
|
4354
|
-
'no-
|
4355
|
-
'no-
|
4356
|
-
'no-
|
4357
|
-
'no-
|
4358
|
-
'no-
|
4359
|
-
'no-
|
4360
|
-
'no-
|
4361
|
-
'no-
|
4362
|
-
'no-
|
4363
|
-
'
|
4364
|
-
'relay-
|
4365
|
-
'relay-
|
4366
|
-
'relay-
|
4367
|
-
'
|
4368
|
-
'require-deprecation-
|
4369
|
-
'require-
|
4370
|
-
'require-
|
4371
|
-
'require-
|
4372
|
-
'
|
4373
|
-
'
|
4374
|
-
'
|
4375
|
-
'unique-
|
4479
|
+
'lone-executable-definition': rule$3,
|
4480
|
+
'match-document-filename': rule$4,
|
4481
|
+
'naming-convention': rule$5,
|
4482
|
+
'no-anonymous-operations': rule$6,
|
4483
|
+
'no-case-insensitive-enum-values-duplicates': rule$7,
|
4484
|
+
'no-deprecated': rule$8,
|
4485
|
+
'no-duplicate-fields': rule$9,
|
4486
|
+
'no-hashtag-description': rule$a,
|
4487
|
+
'no-root-type': rule$b,
|
4488
|
+
'no-scalar-result-type-on-mutation': rule$c,
|
4489
|
+
'no-typename-prefix': rule$d,
|
4490
|
+
'no-unreachable-types': rule$e,
|
4491
|
+
'no-unused-fields': rule$f,
|
4492
|
+
'relay-arguments': rule$g,
|
4493
|
+
'relay-connection-types': rule$h,
|
4494
|
+
'relay-edge-types': rule$i,
|
4495
|
+
'relay-page-info': rule$j,
|
4496
|
+
'require-deprecation-date': rule$k,
|
4497
|
+
'require-deprecation-reason': rule$l,
|
4498
|
+
'require-description': rule$m,
|
4499
|
+
'require-field-of-type-query-in-mutation-result': rule$n,
|
4500
|
+
'require-id-when-available': rule$o,
|
4501
|
+
'selection-set-depth': rule$p,
|
4502
|
+
'strict-id-in-types': rule$q,
|
4503
|
+
'unique-fragment-name': rule$r,
|
4504
|
+
'unique-operation-name': rule$s,
|
4376
4505
|
};
|
4377
4506
|
|
4378
4507
|
// Based on the `eslint-plugin-import`'s cache
|