@graphql-eslint/eslint-plugin 3.19.3-alpha-20230702093957-98f7783 → 3.20.0-alpha-20230703154330-0d51273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{typings → cjs}/cache.d.ts +3 -1
- package/cjs/cache.js +57 -26
- package/{typings → cjs}/configs/index.d.ts +3 -1
- package/cjs/configs/index.js +47 -14
- package/{typings → cjs}/configs/operations-all.d.ts +2 -1
- package/cjs/configs/operations-all.js +47 -30
- package/{typings → cjs}/configs/operations-recommended.d.ts +2 -1
- package/cjs/configs/operations-recommended.js +72 -55
- package/{typings → cjs}/configs/relay.d.ts +2 -1
- package/cjs/configs/relay.js +31 -11
- package/{typings → cjs}/configs/schema-all.d.ts +2 -1
- package/cjs/configs/schema-all.js +41 -24
- package/{typings → cjs}/configs/schema-recommended.d.ts +2 -1
- package/cjs/configs/schema-recommended.js +68 -51
- package/{typings → cjs}/documents.d.ts +4 -1
- package/cjs/documents.js +74 -43
- package/cjs/estree-converter/converter.d.ts +8 -0
- package/cjs/estree-converter/converter.js +80 -59
- package/cjs/estree-converter/index.d.ts +8 -0
- package/cjs/estree-converter/index.js +25 -5
- package/{typings → cjs}/estree-converter/types.d.ts +7 -5
- package/cjs/estree-converter/types.js +16 -0
- package/cjs/estree-converter/utils.d.ts +18 -0
- package/cjs/estree-converter/utils.js +119 -95
- package/{typings → cjs}/flat-configs.d.ts +12 -1
- package/cjs/flat-configs.js +56 -32
- package/cjs/graphql-config.d.ts +13 -0
- package/cjs/graphql-config.js +78 -47
- package/cjs/index.d.ts +22 -0
- package/cjs/index.js +50 -18
- package/cjs/parser.d.ts +12 -0
- package/cjs/parser.js +96 -76
- package/cjs/processor.d.ts +9 -0
- package/cjs/processor.js +119 -88
- package/{typings → cjs}/rules/alphabetize.d.ts +12 -4
- package/cjs/rules/alphabetize.js +337 -295
- package/{typings → cjs}/rules/description-style.d.ts +12 -4
- package/cjs/rules/description-style.js +96 -66
- package/cjs/rules/graphql-js-validation.d.ts +12 -0
- package/cjs/rules/graphql-js-validation.js +595 -433
- package/cjs/rules/index.d.ts +125 -0
- package/cjs/rules/index.js +97 -76
- package/{typings → cjs}/rules/input-name.d.ts +12 -4
- package/cjs/rules/input-name.js +153 -123
- package/{typings → cjs}/rules/lone-executable-definition.d.ts +12 -4
- package/cjs/rules/lone-executable-definition.js +101 -72
- package/{typings → cjs}/rules/match-document-filename.d.ts +14 -6
- package/cjs/rules/match-document-filename.js +229 -182
- package/{typings → cjs}/rules/naming-convention.d.ts +12 -4
- package/cjs/rules/naming-convention.js +380 -316
- package/cjs/rules/no-anonymous-operations.d.ts +12 -0
- package/cjs/rules/no-anonymous-operations.js +88 -57
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.d.ts +12 -0
- package/cjs/rules/no-case-insensitive-enum-values-duplicates.js +82 -50
- package/cjs/rules/no-deprecated.d.ts +12 -0
- package/cjs/rules/no-deprecated.js +106 -75
- package/cjs/rules/no-duplicate-fields.d.ts +12 -0
- package/cjs/rules/no-duplicate-fields.js +116 -82
- package/cjs/rules/no-hashtag-description.d.ts +13 -0
- package/cjs/rules/no-hashtag-description.js +119 -82
- package/cjs/rules/no-one-place-fragments.d.ts +12 -0
- package/cjs/rules/no-one-place-fragments.js +88 -58
- package/{typings → cjs}/rules/no-root-type.d.ts +12 -4
- package/cjs/rules/no-root-type.js +101 -74
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +12 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.js +90 -60
- package/cjs/rules/no-typename-prefix.d.ts +12 -0
- package/cjs/rules/no-typename-prefix.js +88 -55
- package/cjs/rules/no-unreachable-types.d.ts +12 -0
- package/cjs/rules/no-unreachable-types.js +169 -134
- package/cjs/rules/no-unused-fields.d.ts +12 -0
- package/cjs/rules/no-unused-fields.js +117 -92
- package/{typings → cjs}/rules/relay-arguments.d.ts +12 -4
- package/cjs/rules/relay-arguments.js +136 -110
- package/cjs/rules/relay-connection-types.d.ts +13 -0
- package/cjs/rules/relay-connection-types.js +123 -94
- package/{typings → cjs}/rules/relay-edge-types.d.ts +12 -4
- package/cjs/rules/relay-edge-types.js +196 -179
- package/cjs/rules/relay-page-info.d.ts +12 -0
- package/cjs/rules/relay-page-info.js +108 -89
- package/{typings → cjs}/rules/require-deprecation-date.d.ts +12 -4
- package/cjs/rules/require-deprecation-date.js +143 -112
- package/cjs/rules/require-deprecation-reason.d.ts +12 -0
- package/cjs/rules/require-deprecation-reason.js +80 -46
- package/{typings → cjs}/rules/require-description.d.ts +13 -5
- package/cjs/rules/require-description.js +170 -132
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +12 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +81 -51
- package/{typings → cjs}/rules/require-id-when-available.d.ts +12 -4
- package/cjs/rules/require-id-when-available.js +196 -173
- package/cjs/rules/require-import-fragment.d.ts +12 -0
- package/cjs/rules/require-import-fragment.js +138 -88
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +12 -0
- package/cjs/rules/require-nullable-fields-with-oneof.js +80 -50
- package/cjs/rules/require-nullable-result-in-root.d.ts +12 -0
- package/cjs/rules/require-nullable-result-in-root.js +97 -68
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +12 -0
- package/cjs/rules/require-type-pattern-with-oneof.js +70 -42
- package/{typings → cjs}/rules/selection-set-depth.d.ts +12 -4
- package/cjs/rules/selection-set-depth.js +147 -107
- package/{typings → cjs}/rules/strict-id-in-types.d.ts +12 -4
- package/cjs/rules/strict-id-in-types.js +143 -122
- package/cjs/rules/unique-fragment-name.d.ts +13 -0
- package/cjs/rules/unique-fragment-name.js +88 -62
- package/cjs/rules/unique-operation-name.d.ts +12 -0
- package/cjs/rules/unique-operation-name.js +65 -35
- package/cjs/schema.d.ts +12 -0
- package/cjs/schema.js +62 -30
- package/cjs/siblings.d.ts +8 -0
- package/cjs/siblings.js +124 -106
- package/cjs/testkit.d.ts +8 -0
- package/cjs/testkit.js +165 -144
- package/cjs/types-e3367e3c.d.ts +129 -0
- package/cjs/types.d.ts +8 -0
- package/cjs/types.js +16 -0
- package/cjs/utils.d.ts +44 -0
- package/cjs/utils.js +181 -124
- package/{typings/cache.d.cts → esm/cache.d.mts} +3 -1
- package/esm/cache.js +25 -23
- package/{typings/configs/index.d.cts → esm/configs/index.d.mts} +3 -1
- package/esm/configs/index.js +14 -11
- package/{typings/configs/operations-all.d.cts → esm/configs/operations-all.d.mts} +2 -1
- package/esm/configs/operations-all.js +28 -28
- package/{typings/configs/operations-recommended.d.cts → esm/configs/operations-recommended.d.mts} +2 -1
- package/esm/configs/operations-recommended.js +53 -53
- package/{typings/configs/relay.d.cts → esm/configs/relay.d.mts} +2 -1
- package/esm/configs/relay.js +12 -9
- package/{typings/configs/schema-all.d.cts → esm/configs/schema-all.d.mts} +2 -1
- package/esm/configs/schema-all.js +22 -22
- package/{typings/configs/schema-recommended.d.cts → esm/configs/schema-recommended.d.mts} +2 -1
- package/esm/configs/schema-recommended.js +49 -49
- package/{typings/documents.d.cts → esm/documents.d.mts} +4 -1
- package/esm/documents.js +41 -39
- package/esm/estree-converter/converter.d.mts +8 -0
- package/esm/estree-converter/converter.js +63 -57
- package/esm/estree-converter/index.d.mts +8 -0
- package/esm/estree-converter/index.js +3 -3
- package/{typings/estree-converter/types.d.cts → esm/estree-converter/types.d.mts} +7 -5
- package/esm/estree-converter/utils.d.mts +18 -0
- package/esm/estree-converter/utils.js +102 -93
- package/{typings/flat-configs.d.cts → esm/flat-configs.d.mts} +13 -2
- package/esm/flat-configs.js +33 -30
- package/esm/graphql-config.d.mts +13 -0
- package/esm/graphql-config.js +49 -44
- package/esm/index.d.mts +22 -0
- package/esm/index.js +18 -9
- package/esm/package.json +1 -1
- package/esm/parser.d.mts +12 -0
- package/esm/parser.js +64 -73
- package/esm/processor.d.mts +9 -0
- package/esm/processor.js +98 -86
- package/{typings/rules/alphabetize.d.cts → esm/rules/alphabetize.d.mts} +12 -4
- package/esm/rules/alphabetize.js +304 -290
- package/{typings/rules/description-style.d.cts → esm/rules/description-style.d.mts} +12 -4
- package/esm/rules/description-style.js +73 -64
- package/esm/rules/graphql-js-validation.d.mts +12 -0
- package/esm/rules/graphql-js-validation.js +580 -429
- package/esm/rules/index.d.mts +125 -0
- package/esm/rules/index.js +74 -74
- package/{typings/rules/input-name.d.cts → esm/rules/input-name.d.mts} +12 -4
- package/esm/rules/input-name.js +132 -121
- package/{typings/rules/lone-executable-definition.d.cts → esm/rules/lone-executable-definition.d.mts} +12 -4
- package/esm/rules/lone-executable-definition.js +78 -70
- package/{typings/rules/match-document-filename.d.cts → esm/rules/match-document-filename.d.mts} +14 -6
- package/esm/rules/match-document-filename.js +210 -180
- package/{typings/rules/naming-convention.d.cts → esm/rules/naming-convention.d.mts} +12 -4
- package/esm/rules/naming-convention.js +363 -314
- package/esm/rules/no-anonymous-operations.d.mts +12 -0
- package/esm/rules/no-anonymous-operations.js +65 -55
- package/esm/rules/no-case-insensitive-enum-values-duplicates.d.mts +12 -0
- package/esm/rules/no-case-insensitive-enum-values-duplicates.js +59 -48
- package/esm/rules/no-deprecated.d.mts +12 -0
- package/esm/rules/no-deprecated.js +83 -73
- package/esm/rules/no-duplicate-fields.d.mts +12 -0
- package/esm/rules/no-duplicate-fields.js +93 -80
- package/esm/rules/no-hashtag-description.d.mts +13 -0
- package/esm/rules/no-hashtag-description.js +95 -80
- package/esm/rules/no-one-place-fragments.d.mts +12 -0
- package/esm/rules/no-one-place-fragments.js +65 -56
- package/{typings/rules/no-root-type.d.cts → esm/rules/no-root-type.d.mts} +12 -4
- package/esm/rules/no-root-type.js +78 -72
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +12 -0
- package/esm/rules/no-scalar-result-type-on-mutation.js +67 -58
- package/esm/rules/no-typename-prefix.d.mts +12 -0
- package/esm/rules/no-typename-prefix.js +65 -53
- package/esm/rules/no-unreachable-types.d.mts +12 -0
- package/esm/rules/no-unreachable-types.js +141 -131
- package/esm/rules/no-unused-fields.d.mts +12 -0
- package/esm/rules/no-unused-fields.js +94 -90
- package/{typings/rules/relay-arguments.d.cts → esm/rules/relay-arguments.d.mts} +12 -4
- package/esm/rules/relay-arguments.js +113 -108
- package/esm/rules/relay-connection-types.d.mts +13 -0
- package/esm/rules/relay-connection-types.js +98 -91
- package/{typings/rules/relay-edge-types.d.cts → esm/rules/relay-edge-types.d.mts} +12 -4
- package/esm/rules/relay-edge-types.js +178 -177
- package/esm/rules/relay-page-info.d.mts +12 -0
- package/esm/rules/relay-page-info.js +84 -86
- package/{typings/rules/require-deprecation-date.d.cts → esm/rules/require-deprecation-date.d.mts} +12 -4
- package/esm/rules/require-deprecation-date.js +120 -110
- package/esm/rules/require-deprecation-reason.d.mts +12 -0
- package/esm/rules/require-deprecation-reason.js +57 -44
- package/{typings/rules/require-description.d.cts → esm/rules/require-description.d.mts} +13 -5
- package/esm/rules/require-description.js +151 -130
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +12 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +58 -49
- package/{typings/rules/require-id-when-available.d.cts → esm/rules/require-id-when-available.d.mts} +12 -4
- package/esm/rules/require-id-when-available.js +186 -171
- package/esm/rules/require-import-fragment.d.mts +12 -0
- package/esm/rules/require-import-fragment.js +105 -85
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +12 -0
- package/esm/rules/require-nullable-fields-with-oneof.js +57 -48
- package/esm/rules/require-nullable-result-in-root.d.mts +12 -0
- package/esm/rules/require-nullable-result-in-root.js +74 -66
- package/esm/rules/require-type-pattern-with-oneof.d.mts +12 -0
- package/esm/rules/require-type-pattern-with-oneof.js +47 -40
- package/{typings/rules/selection-set-depth.d.cts → esm/rules/selection-set-depth.d.mts} +12 -4
- package/esm/rules/selection-set-depth.js +114 -104
- package/{typings/rules/strict-id-in-types.d.cts → esm/rules/strict-id-in-types.d.mts} +12 -4
- package/esm/rules/strict-id-in-types.js +125 -119
- package/esm/rules/unique-fragment-name.d.mts +13 -0
- package/esm/rules/unique-fragment-name.js +65 -60
- package/esm/rules/unique-operation-name.d.mts +12 -0
- package/esm/rules/unique-operation-name.js +42 -33
- package/esm/schema.d.mts +12 -0
- package/esm/schema.js +29 -26
- package/esm/siblings.d.mts +8 -0
- package/esm/siblings.js +105 -104
- package/esm/testkit.d.mts +8 -0
- package/esm/testkit.js +132 -141
- package/esm/types-2e1afd7c.d.ts +129 -0
- package/esm/types.d.mts +8 -0
- package/esm/utils.d.mts +44 -0
- package/esm/utils.js +138 -116
- package/package.json +40 -30
- package/typings/estree-converter/converter.d.cts +0 -3
- package/typings/estree-converter/converter.d.ts +0 -3
- package/typings/estree-converter/index.d.cts +0 -3
- package/typings/estree-converter/index.d.ts +0 -3
- package/typings/estree-converter/utils.d.cts +0 -13
- package/typings/estree-converter/utils.d.ts +0 -13
- package/typings/graphql-config.d.cts +0 -4
- package/typings/graphql-config.d.ts +0 -4
- package/typings/index.d.cts +0 -10
- package/typings/index.d.ts +0 -10
- package/typings/parser.d.cts +0 -2
- package/typings/parser.d.ts +0 -2
- package/typings/processor.d.cts +0 -6
- package/typings/processor.d.ts +0 -6
- package/typings/rules/graphql-js-validation.d.cts +0 -2
- package/typings/rules/graphql-js-validation.d.ts +0 -2
- package/typings/rules/index.d.cts +0 -111
- package/typings/rules/index.d.ts +0 -111
- package/typings/rules/no-anonymous-operations.d.cts +0 -2
- package/typings/rules/no-anonymous-operations.d.ts +0 -2
- package/typings/rules/no-case-insensitive-enum-values-duplicates.d.cts +0 -2
- package/typings/rules/no-case-insensitive-enum-values-duplicates.d.ts +0 -2
- package/typings/rules/no-deprecated.d.cts +0 -2
- package/typings/rules/no-deprecated.d.ts +0 -2
- package/typings/rules/no-duplicate-fields.d.cts +0 -2
- package/typings/rules/no-duplicate-fields.d.ts +0 -2
- package/typings/rules/no-hashtag-description.d.cts +0 -3
- package/typings/rules/no-hashtag-description.d.ts +0 -3
- package/typings/rules/no-one-place-fragments.d.cts +0 -2
- package/typings/rules/no-one-place-fragments.d.ts +0 -2
- package/typings/rules/no-scalar-result-type-on-mutation.d.cts +0 -2
- package/typings/rules/no-scalar-result-type-on-mutation.d.ts +0 -2
- package/typings/rules/no-typename-prefix.d.cts +0 -2
- package/typings/rules/no-typename-prefix.d.ts +0 -2
- package/typings/rules/no-unreachable-types.d.cts +0 -2
- package/typings/rules/no-unreachable-types.d.ts +0 -2
- package/typings/rules/no-unused-fields.d.cts +0 -2
- package/typings/rules/no-unused-fields.d.ts +0 -2
- package/typings/rules/relay-connection-types.d.cts +0 -4
- package/typings/rules/relay-connection-types.d.ts +0 -4
- package/typings/rules/relay-page-info.d.cts +0 -2
- package/typings/rules/relay-page-info.d.ts +0 -2
- package/typings/rules/require-deprecation-reason.d.cts +0 -2
- package/typings/rules/require-deprecation-reason.d.ts +0 -2
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.cts +0 -2
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -2
- package/typings/rules/require-import-fragment.d.cts +0 -2
- package/typings/rules/require-import-fragment.d.ts +0 -2
- package/typings/rules/require-nullable-fields-with-oneof.d.cts +0 -2
- package/typings/rules/require-nullable-fields-with-oneof.d.ts +0 -2
- package/typings/rules/require-nullable-result-in-root.d.cts +0 -2
- package/typings/rules/require-nullable-result-in-root.d.ts +0 -2
- package/typings/rules/require-type-pattern-with-oneof.d.cts +0 -2
- package/typings/rules/require-type-pattern-with-oneof.d.ts +0 -2
- package/typings/rules/unique-fragment-name.d.cts +0 -5
- package/typings/rules/unique-fragment-name.d.ts +0 -5
- package/typings/rules/unique-operation-name.d.cts +0 -2
- package/typings/rules/unique-operation-name.d.ts +0 -2
- package/typings/schema.d.cts +0 -3
- package/typings/schema.d.ts +0 -3
- package/typings/siblings.d.cts +0 -22
- package/typings/siblings.d.ts +0 -22
- package/typings/testkit.d.cts +0 -29
- package/typings/testkit.d.ts +0 -29
- package/typings/types.d.cts +0 -83
- package/typings/types.d.ts +0 -83
- package/typings/utils.d.cts +0 -40
- package/typings/utils.d.ts +0 -40
@@ -1,256 +1,308 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var graphql_js_validation_exports = {};
|
20
|
+
__export(graphql_js_validation_exports, {
|
21
|
+
GRAPHQL_JS_VALIDATIONS: () => GRAPHQL_JS_VALIDATIONS
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(graphql_js_validation_exports);
|
24
|
+
var import_graphql = require("graphql");
|
25
|
+
var import_validate = require("graphql/validation/validate.js");
|
26
|
+
var import_utils = require("../utils.js");
|
27
|
+
function validateDocument({
|
28
|
+
context,
|
29
|
+
schema = null,
|
30
|
+
documentNode,
|
31
|
+
rule,
|
32
|
+
hasDidYouMeanSuggestions
|
33
|
+
}) {
|
34
|
+
if (documentNode.definitions.length === 0) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
try {
|
38
|
+
const validationErrors = schema ? (0, import_graphql.validate)(schema, documentNode, [rule]) : (0, import_validate.validateSDL)(documentNode, null, [rule]);
|
39
|
+
for (const error of validationErrors) {
|
40
|
+
const { line, column } = error.locations[0];
|
41
|
+
const sourceCode = context.getSourceCode();
|
42
|
+
const { tokens } = sourceCode.ast;
|
43
|
+
const token = tokens.find(
|
44
|
+
(token2) => token2.loc.start.line === line && token2.loc.start.column === column - 1
|
45
|
+
);
|
46
|
+
let loc = {
|
47
|
+
line,
|
48
|
+
column: column - 1
|
49
|
+
};
|
50
|
+
if (token) {
|
51
|
+
loc = // if cursor on `@` symbol than use next node
|
52
|
+
token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
|
53
|
+
}
|
54
|
+
const didYouMeanContent = error.message.match(/Did you mean (?<content>.*)\?$/)?.groups.content;
|
55
|
+
const matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
|
56
|
+
context.report({
|
57
|
+
loc,
|
58
|
+
message: error.message,
|
59
|
+
suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
|
60
|
+
const { name } = match.groups;
|
61
|
+
return {
|
62
|
+
desc: `Rename to \`${name}\``,
|
63
|
+
fix: (fixer) => fixer.replaceText(token, name)
|
64
|
+
};
|
65
|
+
}) : []
|
66
|
+
});
|
54
67
|
}
|
68
|
+
} catch (error) {
|
69
|
+
context.report({
|
70
|
+
loc: import_utils.REPORT_ON_FIRST_CHARACTER,
|
71
|
+
message: error.message
|
72
|
+
});
|
73
|
+
}
|
55
74
|
}
|
56
75
|
const getFragmentDefsAndFragmentSpreads = (node) => {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
76
|
+
const fragmentDefs = /* @__PURE__ */ new Set();
|
77
|
+
const fragmentSpreads = /* @__PURE__ */ new Set();
|
78
|
+
const visitor = {
|
79
|
+
FragmentDefinition(node2) {
|
80
|
+
fragmentDefs.add(node2.name.value);
|
81
|
+
},
|
82
|
+
FragmentSpread(node2) {
|
83
|
+
fragmentSpreads.add(node2.name.value);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
(0, import_graphql.visit)(node, visitor);
|
87
|
+
return { fragmentDefs, fragmentSpreads };
|
69
88
|
};
|
70
89
|
const getMissingFragments = (node) => {
|
71
|
-
|
72
|
-
|
90
|
+
const { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
|
91
|
+
return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
|
73
92
|
};
|
74
93
|
const handleMissingFragments = ({ ruleId, context, node }) => {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
definitions: [...node.definitions, ...fragmentsToAdd],
|
93
|
-
},
|
94
|
-
});
|
94
|
+
const missingFragments = getMissingFragments(node);
|
95
|
+
if (missingFragments.length > 0) {
|
96
|
+
const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context);
|
97
|
+
const fragmentsToAdd = [];
|
98
|
+
for (const fragmentName of missingFragments) {
|
99
|
+
const [foundFragment] = siblings.getFragment(fragmentName).map((source) => source.document);
|
100
|
+
if (foundFragment) {
|
101
|
+
fragmentsToAdd.push(foundFragment);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
if (fragmentsToAdd.length > 0) {
|
105
|
+
return handleMissingFragments({
|
106
|
+
ruleId,
|
107
|
+
context,
|
108
|
+
node: {
|
109
|
+
kind: import_graphql.Kind.DOCUMENT,
|
110
|
+
definitions: [...node.definitions, ...fragmentsToAdd]
|
95
111
|
}
|
112
|
+
});
|
96
113
|
}
|
97
|
-
|
114
|
+
}
|
115
|
+
return node;
|
98
116
|
};
|
99
|
-
const validationToRule = ({
|
100
|
-
|
117
|
+
const validationToRule = ({
|
118
|
+
ruleId,
|
119
|
+
ruleName,
|
120
|
+
getDocumentNode,
|
121
|
+
schema = [],
|
122
|
+
hasDidYouMeanSuggestions
|
123
|
+
}, docs) => {
|
124
|
+
let ruleFn = null;
|
125
|
+
try {
|
126
|
+
ruleFn = require(`graphql/validation/rules/${ruleName}Rule`)[`${ruleName}Rule`];
|
127
|
+
} catch {
|
101
128
|
try {
|
102
|
-
|
129
|
+
ruleFn = require(`graphql/validation/rules/${ruleName}`)[`${ruleName}Rule`];
|
130
|
+
} catch {
|
131
|
+
ruleFn = require("graphql/validation")[`${ruleName}Rule`];
|
103
132
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
133
|
+
}
|
134
|
+
return {
|
135
|
+
[ruleId]: {
|
136
|
+
meta: {
|
137
|
+
docs: {
|
138
|
+
recommended: true,
|
139
|
+
...docs,
|
140
|
+
graphQLJSRuleName: ruleName,
|
141
|
+
url: `https://the-guild.dev/graphql/eslint/rules/${ruleId}`,
|
142
|
+
description: `${docs.description}
|
143
|
+
> This rule is a wrapper around a \`graphql-js\` validation function.`
|
144
|
+
},
|
145
|
+
schema,
|
146
|
+
hasSuggestions: hasDidYouMeanSuggestions
|
147
|
+
},
|
148
|
+
create(context) {
|
149
|
+
if (!ruleFn) {
|
150
|
+
import_utils.logger.warn(
|
151
|
+
`Rule "${ruleId}" depends on a GraphQL validation rule "${ruleName}" but it's not available in the "graphql" version you are using. Skipping\u2026`
|
152
|
+
);
|
153
|
+
return {};
|
110
154
|
}
|
155
|
+
return {
|
156
|
+
Document(node) {
|
157
|
+
const schema2 = docs.requiresSchema ? (0, import_utils.requireGraphQLSchemaFromContext)(ruleId, context) : null;
|
158
|
+
const documentNode = getDocumentNode ? getDocumentNode({ ruleId, context, node: node.rawNode() }) : node.rawNode();
|
159
|
+
validateDocument({
|
160
|
+
context,
|
161
|
+
schema: schema2,
|
162
|
+
documentNode,
|
163
|
+
rule: ruleFn,
|
164
|
+
hasDidYouMeanSuggestions
|
165
|
+
});
|
166
|
+
}
|
167
|
+
};
|
168
|
+
}
|
111
169
|
}
|
112
|
-
|
113
|
-
[ruleId]: {
|
114
|
-
meta: {
|
115
|
-
docs: {
|
116
|
-
recommended: true,
|
117
|
-
...docs,
|
118
|
-
graphQLJSRuleName: ruleName,
|
119
|
-
url: `https://the-guild.dev/graphql/eslint/rules/${ruleId}`,
|
120
|
-
description: `${docs.description}\n> This rule is a wrapper around a \`graphql-js\` validation function.`,
|
121
|
-
},
|
122
|
-
schema,
|
123
|
-
hasSuggestions: hasDidYouMeanSuggestions,
|
124
|
-
},
|
125
|
-
create(context) {
|
126
|
-
if (!ruleFn) {
|
127
|
-
utils_js_1.logger.warn(`Rule "${ruleId}" depends on a GraphQL validation rule "${ruleName}" but it's not available in the "graphql" version you are using. Skipping…`);
|
128
|
-
return {};
|
129
|
-
}
|
130
|
-
return {
|
131
|
-
Document(node) {
|
132
|
-
const schema = docs.requiresSchema
|
133
|
-
? (0, utils_js_1.requireGraphQLSchemaFromContext)(ruleId, context)
|
134
|
-
: null;
|
135
|
-
const documentNode = getDocumentNode
|
136
|
-
? getDocumentNode({ ruleId, context, node: node.rawNode() })
|
137
|
-
: node.rawNode();
|
138
|
-
validateDocument({
|
139
|
-
context,
|
140
|
-
schema,
|
141
|
-
documentNode,
|
142
|
-
rule: ruleFn,
|
143
|
-
hasDidYouMeanSuggestions,
|
144
|
-
});
|
145
|
-
},
|
146
|
-
};
|
147
|
-
},
|
148
|
-
},
|
149
|
-
};
|
170
|
+
};
|
150
171
|
};
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
},
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
172
|
+
const GRAPHQL_JS_VALIDATIONS = Object.assign(
|
173
|
+
{},
|
174
|
+
validationToRule(
|
175
|
+
{
|
176
|
+
ruleId: "executable-definitions",
|
177
|
+
ruleName: "ExecutableDefinitions"
|
178
|
+
},
|
179
|
+
{
|
180
|
+
category: "Operations",
|
181
|
+
description: "A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.",
|
182
|
+
requiresSchema: true
|
183
|
+
}
|
184
|
+
),
|
185
|
+
validationToRule(
|
186
|
+
{
|
187
|
+
ruleId: "fields-on-correct-type",
|
188
|
+
ruleName: "FieldsOnCorrectType",
|
189
|
+
hasDidYouMeanSuggestions: true
|
190
|
+
},
|
191
|
+
{
|
192
|
+
category: "Operations",
|
193
|
+
description: "A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.",
|
194
|
+
requiresSchema: true
|
195
|
+
}
|
196
|
+
),
|
197
|
+
validationToRule(
|
198
|
+
{
|
199
|
+
ruleId: "fragments-on-composite-type",
|
200
|
+
ruleName: "FragmentsOnCompositeTypes"
|
201
|
+
},
|
202
|
+
{
|
203
|
+
category: "Operations",
|
204
|
+
description: "Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.",
|
205
|
+
requiresSchema: true
|
206
|
+
}
|
207
|
+
),
|
208
|
+
validationToRule(
|
209
|
+
{
|
210
|
+
ruleId: "known-argument-names",
|
211
|
+
ruleName: "KnownArgumentNames",
|
212
|
+
hasDidYouMeanSuggestions: true
|
213
|
+
},
|
214
|
+
{
|
215
|
+
category: ["Schema", "Operations"],
|
216
|
+
description: "A GraphQL field is only valid if all supplied arguments are defined by that field.",
|
217
|
+
requiresSchema: true
|
218
|
+
}
|
219
|
+
),
|
220
|
+
validationToRule(
|
221
|
+
{
|
222
|
+
ruleId: "known-directives",
|
223
|
+
ruleName: "KnownDirectives",
|
224
|
+
getDocumentNode({ context, node: documentNode }) {
|
185
225
|
const { ignoreClientDirectives = [] } = context.options[0] || {};
|
186
226
|
if (ignoreClientDirectives.length === 0) {
|
187
|
-
|
227
|
+
return documentNode;
|
188
228
|
}
|
189
|
-
const filterDirectives = (node) => {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
});
|
195
|
-
};
|
196
|
-
return (0, graphql_1.visit)(documentNode, {
|
197
|
-
Field: filterDirectives,
|
198
|
-
OperationDefinition: filterDirectives,
|
229
|
+
const filterDirectives = (node) => ({
|
230
|
+
...node,
|
231
|
+
directives: node.directives?.filter(
|
232
|
+
(directive) => !ignoreClientDirectives.includes(directive.name.value)
|
233
|
+
)
|
199
234
|
});
|
200
|
-
|
201
|
-
|
202
|
-
|
235
|
+
return (0, import_graphql.visit)(documentNode, {
|
236
|
+
Field: filterDirectives,
|
237
|
+
OperationDefinition: filterDirectives
|
238
|
+
});
|
239
|
+
},
|
240
|
+
schema: {
|
241
|
+
type: "array",
|
203
242
|
maxItems: 1,
|
204
243
|
items: {
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
}
|
244
|
+
type: "object",
|
245
|
+
additionalProperties: false,
|
246
|
+
required: ["ignoreClientDirectives"],
|
247
|
+
properties: {
|
248
|
+
ignoreClientDirectives: import_utils.ARRAY_DEFAULT_OPTIONS
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
212
252
|
},
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
253
|
+
{
|
254
|
+
category: ["Schema", "Operations"],
|
255
|
+
description: "A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.",
|
256
|
+
requiresSchema: true,
|
257
|
+
examples: [
|
218
258
|
{
|
219
|
-
|
220
|
-
|
221
|
-
|
259
|
+
title: "Valid",
|
260
|
+
usage: [{ ignoreClientDirectives: ["client"] }],
|
261
|
+
code: (
|
262
|
+
/* GraphQL */
|
263
|
+
`
|
222
264
|
{
|
223
265
|
product {
|
224
266
|
someClientField @client
|
225
267
|
}
|
226
268
|
}
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
269
|
+
`
|
270
|
+
)
|
271
|
+
}
|
272
|
+
]
|
273
|
+
}
|
274
|
+
),
|
275
|
+
validationToRule(
|
276
|
+
{
|
277
|
+
ruleId: "known-fragment-names",
|
278
|
+
ruleName: "KnownFragmentNames",
|
279
|
+
getDocumentNode: handleMissingFragments
|
280
|
+
},
|
281
|
+
{
|
282
|
+
category: "Operations",
|
283
|
+
description: "A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.",
|
284
|
+
requiresSchema: true,
|
285
|
+
requiresSiblings: true,
|
286
|
+
examples: [
|
240
287
|
{
|
241
|
-
|
242
|
-
|
288
|
+
title: "Incorrect",
|
289
|
+
code: (
|
290
|
+
/* GraphQL */
|
291
|
+
`
|
243
292
|
query {
|
244
293
|
user {
|
245
294
|
id
|
246
295
|
...UserFields # fragment not defined in the document
|
247
296
|
}
|
248
297
|
}
|
249
|
-
|
298
|
+
`
|
299
|
+
)
|
250
300
|
},
|
251
301
|
{
|
252
|
-
|
253
|
-
|
302
|
+
title: "Correct",
|
303
|
+
code: (
|
304
|
+
/* GraphQL */
|
305
|
+
`
|
254
306
|
fragment UserFields on User {
|
255
307
|
firstName
|
256
308
|
lastName
|
@@ -262,11 +314,14 @@ exports.GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
262
314
|
...UserFields
|
263
315
|
}
|
264
316
|
}
|
265
|
-
|
317
|
+
`
|
318
|
+
)
|
266
319
|
},
|
267
320
|
{
|
268
|
-
|
269
|
-
|
321
|
+
title: "Correct (`UserFields` fragment located in a separate file)",
|
322
|
+
code: (
|
323
|
+
/* GraphQL */
|
324
|
+
`
|
270
325
|
# user.gql
|
271
326
|
query {
|
272
327
|
user {
|
@@ -279,224 +334,331 @@ exports.GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
279
334
|
fragment UserFields on User {
|
280
335
|
id
|
281
336
|
}
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
}
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
337
|
+
`
|
338
|
+
)
|
339
|
+
}
|
340
|
+
]
|
341
|
+
}
|
342
|
+
),
|
343
|
+
validationToRule(
|
344
|
+
{
|
345
|
+
ruleId: "known-type-names",
|
346
|
+
ruleName: "KnownTypeNames",
|
347
|
+
hasDidYouMeanSuggestions: true
|
348
|
+
},
|
349
|
+
{
|
350
|
+
category: ["Schema", "Operations"],
|
351
|
+
description: "A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.",
|
352
|
+
requiresSchema: true
|
353
|
+
}
|
354
|
+
),
|
355
|
+
validationToRule(
|
356
|
+
{
|
357
|
+
ruleId: "lone-anonymous-operation",
|
358
|
+
ruleName: "LoneAnonymousOperation"
|
359
|
+
},
|
360
|
+
{
|
361
|
+
category: "Operations",
|
362
|
+
description: "A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if it contains only that one operation definition.",
|
363
|
+
requiresSchema: true
|
364
|
+
}
|
365
|
+
),
|
366
|
+
validationToRule(
|
367
|
+
{
|
368
|
+
ruleId: "lone-schema-definition",
|
369
|
+
ruleName: "LoneSchemaDefinition"
|
370
|
+
},
|
371
|
+
{
|
372
|
+
category: "Schema",
|
373
|
+
description: "A GraphQL document is only valid if it contains only one schema definition."
|
374
|
+
}
|
375
|
+
),
|
376
|
+
validationToRule(
|
377
|
+
{
|
378
|
+
ruleId: "no-fragment-cycles",
|
379
|
+
ruleName: "NoFragmentCycles"
|
380
|
+
},
|
381
|
+
{
|
382
|
+
category: "Operations",
|
383
|
+
description: "A GraphQL fragment is only valid when it does not have cycles in fragments usage.",
|
384
|
+
requiresSchema: true
|
385
|
+
}
|
386
|
+
),
|
387
|
+
validationToRule(
|
388
|
+
{
|
389
|
+
ruleId: "no-undefined-variables",
|
390
|
+
ruleName: "NoUndefinedVariables",
|
391
|
+
getDocumentNode: handleMissingFragments
|
392
|
+
},
|
393
|
+
{
|
394
|
+
category: "Operations",
|
395
|
+
description: "A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.",
|
396
|
+
requiresSchema: true,
|
397
|
+
requiresSiblings: true
|
398
|
+
}
|
399
|
+
),
|
400
|
+
validationToRule(
|
401
|
+
{
|
402
|
+
ruleId: "no-unused-fragments",
|
403
|
+
ruleName: "NoUnusedFragments",
|
404
|
+
getDocumentNode: ({ ruleId, context, node }) => {
|
405
|
+
const siblings = (0, import_utils.requireSiblingsOperations)(ruleId, context);
|
327
406
|
const FilePathToDocumentsMap = [
|
328
|
-
|
329
|
-
|
407
|
+
...siblings.getOperations(),
|
408
|
+
...siblings.getFragments()
|
330
409
|
].reduce((map, { filePath, document }) => {
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
}
|
410
|
+
map[filePath] ??= [];
|
411
|
+
map[filePath].push(document);
|
412
|
+
return map;
|
413
|
+
}, /* @__PURE__ */ Object.create(null));
|
414
|
+
const getParentNode = (currentFilePath, node2) => {
|
415
|
+
const { fragmentDefs } = getFragmentDefsAndFragmentSpreads(node2);
|
416
|
+
if (fragmentDefs.size === 0) {
|
417
|
+
return node2;
|
418
|
+
}
|
419
|
+
delete FilePathToDocumentsMap[currentFilePath];
|
420
|
+
for (const [filePath, documents] of Object.entries(FilePathToDocumentsMap)) {
|
421
|
+
const missingFragments = getMissingFragments({
|
422
|
+
kind: import_graphql.Kind.DOCUMENT,
|
423
|
+
definitions: documents
|
424
|
+
});
|
425
|
+
const isCurrentFileImportFragment = missingFragments.some(
|
426
|
+
(fragment) => fragmentDefs.has(fragment)
|
427
|
+
);
|
428
|
+
if (isCurrentFileImportFragment) {
|
429
|
+
return getParentNode(filePath, {
|
430
|
+
kind: import_graphql.Kind.DOCUMENT,
|
431
|
+
definitions: [...node2.definitions, ...documents]
|
432
|
+
});
|
355
433
|
}
|
356
|
-
|
434
|
+
}
|
435
|
+
return node2;
|
357
436
|
};
|
358
437
|
return getParentNode(context.getFilename(), node);
|
438
|
+
}
|
439
|
+
},
|
440
|
+
{
|
441
|
+
category: "Operations",
|
442
|
+
description: "A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.",
|
443
|
+
requiresSchema: true,
|
444
|
+
requiresSiblings: true
|
445
|
+
}
|
446
|
+
),
|
447
|
+
validationToRule(
|
448
|
+
{
|
449
|
+
ruleId: "no-unused-variables",
|
450
|
+
ruleName: "NoUnusedVariables",
|
451
|
+
getDocumentNode: handleMissingFragments
|
452
|
+
},
|
453
|
+
{
|
454
|
+
category: "Operations",
|
455
|
+
description: "A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.",
|
456
|
+
requiresSchema: true,
|
457
|
+
requiresSiblings: true
|
458
|
+
}
|
459
|
+
),
|
460
|
+
validationToRule(
|
461
|
+
{
|
462
|
+
ruleId: "overlapping-fields-can-be-merged",
|
463
|
+
ruleName: "OverlappingFieldsCanBeMerged"
|
464
|
+
},
|
465
|
+
{
|
466
|
+
category: "Operations",
|
467
|
+
description: "A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.",
|
468
|
+
requiresSchema: true
|
469
|
+
}
|
470
|
+
),
|
471
|
+
validationToRule(
|
472
|
+
{
|
473
|
+
ruleId: "possible-fragment-spread",
|
474
|
+
ruleName: "PossibleFragmentSpreads"
|
475
|
+
},
|
476
|
+
{
|
477
|
+
category: "Operations",
|
478
|
+
description: "A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.",
|
479
|
+
requiresSchema: true
|
480
|
+
}
|
481
|
+
),
|
482
|
+
validationToRule(
|
483
|
+
{
|
484
|
+
ruleId: "possible-type-extension",
|
485
|
+
ruleName: "PossibleTypeExtensions",
|
486
|
+
hasDidYouMeanSuggestions: true
|
487
|
+
},
|
488
|
+
{
|
489
|
+
category: "Schema",
|
490
|
+
description: "A type extension is only valid if the type is defined and has the same kind.",
|
491
|
+
// TODO: add in graphql-eslint v4
|
492
|
+
recommended: false,
|
493
|
+
requiresSchema: true,
|
494
|
+
isDisabledForAllConfig: true
|
495
|
+
}
|
496
|
+
),
|
497
|
+
validationToRule(
|
498
|
+
{
|
499
|
+
ruleId: "provided-required-arguments",
|
500
|
+
ruleName: "ProvidedRequiredArguments"
|
501
|
+
},
|
502
|
+
{
|
503
|
+
category: ["Schema", "Operations"],
|
504
|
+
description: "A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.",
|
505
|
+
requiresSchema: true
|
506
|
+
}
|
507
|
+
),
|
508
|
+
validationToRule(
|
509
|
+
{
|
510
|
+
ruleId: "scalar-leafs",
|
511
|
+
ruleName: "ScalarLeafs",
|
512
|
+
hasDidYouMeanSuggestions: true
|
513
|
+
},
|
514
|
+
{
|
515
|
+
category: "Operations",
|
516
|
+
description: "A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.",
|
517
|
+
requiresSchema: true
|
518
|
+
}
|
519
|
+
),
|
520
|
+
validationToRule(
|
521
|
+
{
|
522
|
+
ruleId: "one-field-subscriptions",
|
523
|
+
ruleName: "SingleFieldSubscriptions"
|
524
|
+
},
|
525
|
+
{
|
526
|
+
category: "Operations",
|
527
|
+
description: "A GraphQL subscription is valid only if it contains a single root field.",
|
528
|
+
requiresSchema: true
|
529
|
+
}
|
530
|
+
),
|
531
|
+
validationToRule(
|
532
|
+
{
|
533
|
+
ruleId: "unique-argument-names",
|
534
|
+
ruleName: "UniqueArgumentNames"
|
359
535
|
},
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
}
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
}
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
})
|
489
|
-
ruleId: 'variables-are-input-types',
|
490
|
-
ruleName: 'VariablesAreInputTypes',
|
491
|
-
}, {
|
492
|
-
category: 'Operations',
|
493
|
-
description: 'A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).',
|
494
|
-
requiresSchema: true,
|
495
|
-
}), validationToRule({
|
496
|
-
ruleId: 'variables-in-allowed-position',
|
497
|
-
ruleName: 'VariablesInAllowedPosition',
|
498
|
-
}, {
|
499
|
-
category: 'Operations',
|
500
|
-
description: 'Variables passed to field arguments conform to type.',
|
501
|
-
requiresSchema: true,
|
502
|
-
}));
|
536
|
+
{
|
537
|
+
category: "Operations",
|
538
|
+
description: "A GraphQL field or directive is only valid if all supplied arguments are uniquely named.",
|
539
|
+
requiresSchema: true
|
540
|
+
}
|
541
|
+
),
|
542
|
+
validationToRule(
|
543
|
+
{
|
544
|
+
ruleId: "unique-directive-names",
|
545
|
+
ruleName: "UniqueDirectiveNames"
|
546
|
+
},
|
547
|
+
{
|
548
|
+
category: "Schema",
|
549
|
+
description: "A GraphQL document is only valid if all defined directives have unique names."
|
550
|
+
}
|
551
|
+
),
|
552
|
+
validationToRule(
|
553
|
+
{
|
554
|
+
ruleId: "unique-directive-names-per-location",
|
555
|
+
ruleName: "UniqueDirectivesPerLocation"
|
556
|
+
},
|
557
|
+
{
|
558
|
+
category: ["Schema", "Operations"],
|
559
|
+
description: "A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.",
|
560
|
+
requiresSchema: true
|
561
|
+
}
|
562
|
+
),
|
563
|
+
validationToRule(
|
564
|
+
{
|
565
|
+
ruleId: "unique-enum-value-names",
|
566
|
+
ruleName: "UniqueEnumValueNames"
|
567
|
+
},
|
568
|
+
{
|
569
|
+
category: "Schema",
|
570
|
+
description: "A GraphQL enum type is only valid if all its values are uniquely named.",
|
571
|
+
recommended: false,
|
572
|
+
isDisabledForAllConfig: true
|
573
|
+
}
|
574
|
+
),
|
575
|
+
validationToRule(
|
576
|
+
{
|
577
|
+
ruleId: "unique-field-definition-names",
|
578
|
+
ruleName: "UniqueFieldDefinitionNames"
|
579
|
+
},
|
580
|
+
{
|
581
|
+
category: "Schema",
|
582
|
+
description: "A GraphQL complex type is only valid if all its fields are uniquely named."
|
583
|
+
}
|
584
|
+
),
|
585
|
+
validationToRule(
|
586
|
+
{
|
587
|
+
ruleId: "unique-input-field-names",
|
588
|
+
ruleName: "UniqueInputFieldNames"
|
589
|
+
},
|
590
|
+
{
|
591
|
+
category: "Operations",
|
592
|
+
description: "A GraphQL input object value is only valid if all supplied fields are uniquely named."
|
593
|
+
}
|
594
|
+
),
|
595
|
+
validationToRule(
|
596
|
+
{
|
597
|
+
ruleId: "unique-operation-types",
|
598
|
+
ruleName: "UniqueOperationTypes"
|
599
|
+
},
|
600
|
+
{
|
601
|
+
category: "Schema",
|
602
|
+
description: "A GraphQL document is only valid if it has only one type per operation."
|
603
|
+
}
|
604
|
+
),
|
605
|
+
validationToRule(
|
606
|
+
{
|
607
|
+
ruleId: "unique-type-names",
|
608
|
+
ruleName: "UniqueTypeNames"
|
609
|
+
},
|
610
|
+
{
|
611
|
+
category: "Schema",
|
612
|
+
description: "A GraphQL document is only valid if all defined types have unique names."
|
613
|
+
}
|
614
|
+
),
|
615
|
+
validationToRule(
|
616
|
+
{
|
617
|
+
ruleId: "unique-variable-names",
|
618
|
+
ruleName: "UniqueVariableNames"
|
619
|
+
},
|
620
|
+
{
|
621
|
+
category: "Operations",
|
622
|
+
description: "A GraphQL operation is only valid if all its variables are uniquely named.",
|
623
|
+
requiresSchema: true
|
624
|
+
}
|
625
|
+
),
|
626
|
+
validationToRule(
|
627
|
+
{
|
628
|
+
ruleId: "value-literals-of-correct-type",
|
629
|
+
ruleName: "ValuesOfCorrectType",
|
630
|
+
hasDidYouMeanSuggestions: true
|
631
|
+
},
|
632
|
+
{
|
633
|
+
category: "Operations",
|
634
|
+
description: "A GraphQL document is only valid if all value literals are of the type expected at their position.",
|
635
|
+
requiresSchema: true
|
636
|
+
}
|
637
|
+
),
|
638
|
+
validationToRule(
|
639
|
+
{
|
640
|
+
ruleId: "variables-are-input-types",
|
641
|
+
ruleName: "VariablesAreInputTypes"
|
642
|
+
},
|
643
|
+
{
|
644
|
+
category: "Operations",
|
645
|
+
description: "A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).",
|
646
|
+
requiresSchema: true
|
647
|
+
}
|
648
|
+
),
|
649
|
+
validationToRule(
|
650
|
+
{
|
651
|
+
ruleId: "variables-in-allowed-position",
|
652
|
+
ruleName: "VariablesInAllowedPosition"
|
653
|
+
},
|
654
|
+
{
|
655
|
+
category: "Operations",
|
656
|
+
description: "Variables passed to field arguments conform to type.",
|
657
|
+
requiresSchema: true
|
658
|
+
}
|
659
|
+
)
|
660
|
+
);
|
661
|
+
// Annotate the CommonJS export names for ESM import in node:
|
662
|
+
0 && (module.exports = {
|
663
|
+
GRAPHQL_JS_VALIDATIONS
|
664
|
+
});
|