@graphql-eslint/eslint-plugin 4.0.0-alpha.12 → 4.0.0-alpha.14
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/meta.js +1 -1
- package/cjs/rules/no-deprecated/index.js +15 -5
- package/cjs/rules/no-unreachable-types/index.js +3 -4
- package/cjs/utils.d.cts +1 -1
- package/cjs/utils.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/meta.js +1 -1
- package/esm/rules/index.d.ts +1 -1
- package/esm/rules/no-deprecated/index.js +16 -6
- package/esm/rules/no-unreachable-types/index.js +3 -4
- package/esm/utils.d.ts +1 -1
- package/esm/utils.js +1 -1
- package/index.browser.js +90 -81
- package/package.json +1 -1
package/cjs/meta.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../../chunk-UIAXBAMD.js');
|
2
|
-
var _graphql = require('graphql');
|
3
2
|
var _utilsjs = require('../../utils.js');
|
4
3
|
const RULE_ID = "no-deprecated", rule = exports.rule = {
|
5
4
|
meta: {
|
@@ -84,24 +83,24 @@ const RULE_ID = "no-deprecated", rule = exports.rule = {
|
|
84
83
|
recommended: !0
|
85
84
|
},
|
86
85
|
messages: {
|
87
|
-
[RULE_ID]: "
|
86
|
+
[RULE_ID]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
|
88
87
|
},
|
89
88
|
schema: []
|
90
89
|
},
|
91
90
|
create(context) {
|
92
91
|
_utilsjs.requireGraphQLSchemaFromContext.call(void 0, RULE_ID, context);
|
93
92
|
function report(node, reason) {
|
94
|
-
const
|
93
|
+
const nodeType = _utilsjs.displayNodeName.call(void 0, node);
|
95
94
|
context.report({
|
96
95
|
node,
|
97
96
|
messageId: RULE_ID,
|
98
97
|
data: {
|
99
|
-
type: nodeType,
|
98
|
+
type: nodeType[0].toUpperCase() + nodeType.slice(1),
|
100
99
|
reason
|
101
100
|
},
|
102
101
|
suggest: [
|
103
102
|
{
|
104
|
-
desc: `Remove
|
103
|
+
desc: `Remove ${nodeType}`,
|
105
104
|
fix: (fixer) => fixer.remove(node)
|
106
105
|
}
|
107
106
|
]
|
@@ -115,6 +114,17 @@ const RULE_ID = "no-deprecated", rule = exports.rule = {
|
|
115
114
|
Field(node) {
|
116
115
|
const reason = _optionalChain([node, 'access', _5 => _5.typeInfo, 'call', _6 => _6(), 'access', _7 => _7.fieldDef, 'optionalAccess', _8 => _8.deprecationReason]);
|
117
116
|
reason && report(node, reason);
|
117
|
+
},
|
118
|
+
Argument(node) {
|
119
|
+
const reason = _optionalChain([node, 'access', _9 => _9.typeInfo, 'call', _10 => _10(), 'access', _11 => _11.argument, 'optionalAccess', _12 => _12.deprecationReason]);
|
120
|
+
reason && report(node, reason);
|
121
|
+
},
|
122
|
+
ObjectValue(node) {
|
123
|
+
const fields = node.typeInfo().inputType.getFields();
|
124
|
+
for (const field of node.fields) {
|
125
|
+
const fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
|
126
|
+
reason && report(field, reason);
|
127
|
+
}
|
118
128
|
}
|
119
129
|
};
|
120
130
|
}
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
|
7
8
|
var _graphql = require('graphql');
|
8
9
|
var _lodashlowercase = require('lodash.lowercase'); var _lodashlowercase2 = _interopRequireDefault(_lodashlowercase);
|
9
10
|
var _cachejs = require('../../cache.js');
|
@@ -67,10 +68,8 @@ function getReachableTypes(schema) {
|
|
67
68
|
for (const node of schema.getDirectives())
|
68
69
|
if (node.locations.some((location) => RequestDirectiveLocations.has(location))) {
|
69
70
|
reachableTypes.add(node.name);
|
70
|
-
for (const arg of node.args)
|
71
|
-
|
72
|
-
argTypeName && reachableTypes.add(argTypeName);
|
73
|
-
}
|
71
|
+
for (const arg of node.args)
|
72
|
+
reachableTypes.add(_graphql.getNamedType.call(void 0, arg.type).name);
|
74
73
|
}
|
75
74
|
return reachableTypesCache.set(schema, reachableTypes), reachableTypes;
|
76
75
|
}
|
package/cjs/utils.d.cts
CHANGED
@@ -39,7 +39,7 @@ declare const ARRAY_DEFAULT_OPTIONS: {
|
|
39
39
|
declare const englishJoinWords: (words: string[]) => string;
|
40
40
|
type Truthy<T> = T extends '' | 0 | false | null | undefined ? never : T;
|
41
41
|
declare function truthy<T>(value: T): value is Truthy<T>;
|
42
|
-
declare function displayNodeName(node: GraphQLESTreeNode<ASTNode>): string;
|
42
|
+
declare function displayNodeName(node: GraphQLESTreeNode<ASTNode, boolean>): string;
|
43
43
|
declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
|
44
44
|
|
45
45
|
export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, slash, truthy };
|
package/cjs/utils.js
CHANGED
@@ -123,7 +123,7 @@ const DisplayNodeNameMap = {
|
|
123
123
|
[_graphql.Kind.VARIABLE]: "variable"
|
124
124
|
};
|
125
125
|
function displayNodeName(node) {
|
126
|
-
return `${node.kind === _graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && _optionalChain([node, 'access', _ => _.alias, 'optionalAccess', _2 => _2.value]) || "name" in node && _optionalChain([node, 'access', _3 => _3.name, 'optionalAccess', _4 => _4.value])}"`;
|
126
|
+
return `${node.kind === _graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && _optionalChain([node, 'access', _ => _.alias, 'optionalAccess', _2 => _2.value]) || "name" in node && _optionalChain([node, 'access', _3 => _3.name, 'optionalAccess', _4 => _4.value]) || node.value}"`;
|
127
127
|
}
|
128
128
|
function getNodeName(node) {
|
129
129
|
switch (node.kind) {
|
package/esm/index.d.ts
CHANGED
@@ -48,10 +48,10 @@ declare const _default: {
|
|
48
48
|
};
|
49
49
|
rules: {
|
50
50
|
alphabetize: GraphQLESLintRule<{
|
51
|
-
values?: boolean | undefined;
|
52
51
|
definitions?: boolean | undefined;
|
53
52
|
selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
|
54
53
|
arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
|
54
|
+
values?: boolean | undefined;
|
55
55
|
fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
|
56
56
|
variables?: boolean | undefined;
|
57
57
|
groups?: string[] | undefined;
|
package/esm/meta.js
CHANGED
package/esm/rules/index.d.ts
CHANGED
@@ -12,10 +12,10 @@ import 'json-schema-to-ts';
|
|
12
12
|
|
13
13
|
declare const rules: {
|
14
14
|
alphabetize: GraphQLESLintRule<{
|
15
|
-
values?: boolean | undefined;
|
16
15
|
definitions?: boolean | undefined;
|
17
16
|
selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
|
18
17
|
arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
|
18
|
+
values?: boolean | undefined;
|
19
19
|
fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
|
20
20
|
variables?: boolean | undefined;
|
21
21
|
groups?: string[] | undefined;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import "../../chunk-UIAXBAMD.js";
|
2
|
-
import {
|
3
|
-
import { requireGraphQLSchemaFromContext } from "../../utils.js";
|
2
|
+
import { displayNodeName, requireGraphQLSchemaFromContext } from "../../utils.js";
|
4
3
|
const RULE_ID = "no-deprecated", rule = {
|
5
4
|
meta: {
|
6
5
|
type: "suggestion",
|
@@ -84,24 +83,24 @@ const RULE_ID = "no-deprecated", rule = {
|
|
84
83
|
recommended: !0
|
85
84
|
},
|
86
85
|
messages: {
|
87
|
-
[RULE_ID]: "
|
86
|
+
[RULE_ID]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
|
88
87
|
},
|
89
88
|
schema: []
|
90
89
|
},
|
91
90
|
create(context) {
|
92
91
|
requireGraphQLSchemaFromContext(RULE_ID, context);
|
93
92
|
function report(node, reason) {
|
94
|
-
const
|
93
|
+
const nodeType = displayNodeName(node);
|
95
94
|
context.report({
|
96
95
|
node,
|
97
96
|
messageId: RULE_ID,
|
98
97
|
data: {
|
99
|
-
type: nodeType,
|
98
|
+
type: nodeType[0].toUpperCase() + nodeType.slice(1),
|
100
99
|
reason
|
101
100
|
},
|
102
101
|
suggest: [
|
103
102
|
{
|
104
|
-
desc: `Remove
|
103
|
+
desc: `Remove ${nodeType}`,
|
105
104
|
fix: (fixer) => fixer.remove(node)
|
106
105
|
}
|
107
106
|
]
|
@@ -115,6 +114,17 @@ const RULE_ID = "no-deprecated", rule = {
|
|
115
114
|
Field(node) {
|
116
115
|
const reason = node.typeInfo().fieldDef?.deprecationReason;
|
117
116
|
reason && report(node, reason);
|
117
|
+
},
|
118
|
+
Argument(node) {
|
119
|
+
const reason = node.typeInfo().argument?.deprecationReason;
|
120
|
+
reason && report(node, reason);
|
121
|
+
},
|
122
|
+
ObjectValue(node) {
|
123
|
+
const fields = node.typeInfo().inputType.getFields();
|
124
|
+
for (const field of node.fields) {
|
125
|
+
const fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
|
126
|
+
reason && report(field, reason);
|
127
|
+
}
|
118
128
|
}
|
119
129
|
};
|
120
130
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import "../../chunk-UIAXBAMD.js";
|
2
2
|
import {
|
3
3
|
DirectiveLocation,
|
4
|
+
getNamedType,
|
4
5
|
isInterfaceType,
|
5
6
|
Kind,
|
6
7
|
visit
|
@@ -67,10 +68,8 @@ function getReachableTypes(schema) {
|
|
67
68
|
for (const node of schema.getDirectives())
|
68
69
|
if (node.locations.some((location) => RequestDirectiveLocations.has(location))) {
|
69
70
|
reachableTypes.add(node.name);
|
70
|
-
for (const arg of node.args)
|
71
|
-
|
72
|
-
argTypeName && reachableTypes.add(argTypeName);
|
73
|
-
}
|
71
|
+
for (const arg of node.args)
|
72
|
+
reachableTypes.add(getNamedType(arg.type).name);
|
74
73
|
}
|
75
74
|
return reachableTypesCache.set(schema, reachableTypes), reachableTypes;
|
76
75
|
}
|
package/esm/utils.d.ts
CHANGED
@@ -39,7 +39,7 @@ declare const ARRAY_DEFAULT_OPTIONS: {
|
|
39
39
|
declare const englishJoinWords: (words: string[]) => string;
|
40
40
|
type Truthy<T> = T extends '' | 0 | false | null | undefined ? never : T;
|
41
41
|
declare function truthy<T>(value: T): value is Truthy<T>;
|
42
|
-
declare function displayNodeName(node: GraphQLESTreeNode<ASTNode>): string;
|
42
|
+
declare function displayNodeName(node: GraphQLESTreeNode<ASTNode, boolean>): string;
|
43
43
|
declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
|
44
44
|
|
45
45
|
export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, slash, truthy };
|
package/esm/utils.js
CHANGED
@@ -123,7 +123,7 @@ const DisplayNodeNameMap = {
|
|
123
123
|
[Kind.VARIABLE]: "variable"
|
124
124
|
};
|
125
125
|
function displayNodeName(node) {
|
126
|
-
return `${node.kind === Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
|
126
|
+
return `${node.kind === Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value || node.value}"`;
|
127
127
|
}
|
128
128
|
function getNodeName(node) {
|
129
129
|
switch (node.kind) {
|
package/index.browser.js
CHANGED
@@ -521,7 +521,7 @@ var DisplayNodeNameMap = {
|
|
521
521
|
[Kind2.VARIABLE]: "variable"
|
522
522
|
};
|
523
523
|
function displayNodeName(node) {
|
524
|
-
return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
|
524
|
+
return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value || node.value}"`;
|
525
525
|
}
|
526
526
|
function getNodeName(node) {
|
527
527
|
switch (node.kind) {
|
@@ -2596,7 +2596,6 @@ var RULE_ID3 = "no-anonymous-operations", rule7 = {
|
|
2596
2596
|
};
|
2597
2597
|
|
2598
2598
|
// src/rules/no-deprecated/index.ts
|
2599
|
-
import { Kind as Kind10 } from "graphql";
|
2600
2599
|
var RULE_ID4 = "no-deprecated", rule8 = {
|
2601
2600
|
meta: {
|
2602
2601
|
type: "suggestion",
|
@@ -2680,24 +2679,24 @@ var RULE_ID4 = "no-deprecated", rule8 = {
|
|
2680
2679
|
recommended: !0
|
2681
2680
|
},
|
2682
2681
|
messages: {
|
2683
|
-
[RULE_ID4]: "
|
2682
|
+
[RULE_ID4]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
|
2684
2683
|
},
|
2685
2684
|
schema: []
|
2686
2685
|
},
|
2687
2686
|
create(context) {
|
2688
2687
|
requireGraphQLSchemaFromContext(RULE_ID4, context);
|
2689
2688
|
function report(node, reason) {
|
2690
|
-
let
|
2689
|
+
let nodeType = displayNodeName(node);
|
2691
2690
|
context.report({
|
2692
2691
|
node,
|
2693
2692
|
messageId: RULE_ID4,
|
2694
2693
|
data: {
|
2695
|
-
type: nodeType,
|
2694
|
+
type: nodeType[0].toUpperCase() + nodeType.slice(1),
|
2696
2695
|
reason
|
2697
2696
|
},
|
2698
2697
|
suggest: [
|
2699
2698
|
{
|
2700
|
-
desc: `Remove
|
2699
|
+
desc: `Remove ${nodeType}`,
|
2701
2700
|
fix: (fixer) => fixer.remove(node)
|
2702
2701
|
}
|
2703
2702
|
]
|
@@ -2711,13 +2710,24 @@ var RULE_ID4 = "no-deprecated", rule8 = {
|
|
2711
2710
|
Field(node) {
|
2712
2711
|
let reason = node.typeInfo().fieldDef?.deprecationReason;
|
2713
2712
|
reason && report(node, reason);
|
2713
|
+
},
|
2714
|
+
Argument(node) {
|
2715
|
+
let reason = node.typeInfo().argument?.deprecationReason;
|
2716
|
+
reason && report(node, reason);
|
2717
|
+
},
|
2718
|
+
ObjectValue(node) {
|
2719
|
+
let fields = node.typeInfo().inputType.getFields();
|
2720
|
+
for (let field of node.fields) {
|
2721
|
+
let fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
|
2722
|
+
reason && report(field, reason);
|
2723
|
+
}
|
2714
2724
|
}
|
2715
2725
|
};
|
2716
2726
|
}
|
2717
2727
|
};
|
2718
2728
|
|
2719
2729
|
// src/rules/no-duplicate-fields/index.ts
|
2720
|
-
import { Kind as
|
2730
|
+
import { Kind as Kind10 } from "graphql";
|
2721
2731
|
var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
2722
2732
|
meta: {
|
2723
2733
|
type: "suggestion",
|
@@ -2801,7 +2811,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
|
2801
2811
|
desc: `Remove \`${fieldName}\` ${parent.type.toLowerCase()}`,
|
2802
2812
|
fix(fixer) {
|
2803
2813
|
return fixer.remove(
|
2804
|
-
parent.type ===
|
2814
|
+
parent.type === Kind10.VARIABLE ? parent.parent : parent
|
2805
2815
|
);
|
2806
2816
|
}
|
2807
2817
|
}
|
@@ -2824,7 +2834,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
|
|
2824
2834
|
SelectionSet(node) {
|
2825
2835
|
let set = /* @__PURE__ */ new Set();
|
2826
2836
|
for (let selection of node.selections)
|
2827
|
-
selection.kind ===
|
2837
|
+
selection.kind === Kind10.FIELD && checkNode2(set, selection.alias || selection.name);
|
2828
2838
|
}
|
2829
2839
|
};
|
2830
2840
|
}
|
@@ -3094,7 +3104,7 @@ var schema7 = {
|
|
3094
3104
|
};
|
3095
3105
|
|
3096
3106
|
// src/rules/no-scalar-result-type-on-mutation/index.ts
|
3097
|
-
import { isScalarType, Kind as
|
3107
|
+
import { isScalarType, Kind as Kind11 } from "graphql";
|
3098
3108
|
var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
|
3099
3109
|
meta: {
|
3100
3110
|
type: "suggestion",
|
@@ -3141,7 +3151,7 @@ var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
|
|
3141
3151
|
let typeName = node.value, graphQLType = schema16.getType(typeName);
|
3142
3152
|
if (isScalarType(graphQLType)) {
|
3143
3153
|
let fieldDef = node.parent;
|
3144
|
-
for (; fieldDef.kind !==
|
3154
|
+
for (; fieldDef.kind !== Kind11.FIELD_DEFINITION; )
|
3145
3155
|
fieldDef = fieldDef.parent;
|
3146
3156
|
context.report({
|
3147
3157
|
node,
|
@@ -3231,25 +3241,26 @@ var NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule14 = {
|
|
3231
3241
|
// src/rules/no-unreachable-types/index.ts
|
3232
3242
|
import {
|
3233
3243
|
DirectiveLocation,
|
3244
|
+
getNamedType,
|
3234
3245
|
isInterfaceType,
|
3235
|
-
Kind as
|
3246
|
+
Kind as Kind12,
|
3236
3247
|
visit as visit5
|
3237
3248
|
} from "graphql";
|
3238
3249
|
import lowerCase3 from "lodash.lowercase";
|
3239
3250
|
var RULE_ID9 = "no-unreachable-types", KINDS = [
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3251
|
+
Kind12.DIRECTIVE_DEFINITION,
|
3252
|
+
Kind12.OBJECT_TYPE_DEFINITION,
|
3253
|
+
Kind12.OBJECT_TYPE_EXTENSION,
|
3254
|
+
Kind12.INTERFACE_TYPE_DEFINITION,
|
3255
|
+
Kind12.INTERFACE_TYPE_EXTENSION,
|
3256
|
+
Kind12.SCALAR_TYPE_DEFINITION,
|
3257
|
+
Kind12.SCALAR_TYPE_EXTENSION,
|
3258
|
+
Kind12.INPUT_OBJECT_TYPE_DEFINITION,
|
3259
|
+
Kind12.INPUT_OBJECT_TYPE_EXTENSION,
|
3260
|
+
Kind12.UNION_TYPE_DEFINITION,
|
3261
|
+
Kind12.UNION_TYPE_EXTENSION,
|
3262
|
+
Kind12.ENUM_TYPE_DEFINITION,
|
3263
|
+
Kind12.ENUM_TYPE_EXTENSION
|
3253
3264
|
], reachableTypesCache = new ModuleCache(), RequestDirectiveLocations = /* @__PURE__ */ new Set([
|
3254
3265
|
DirectiveLocation.QUERY,
|
3255
3266
|
DirectiveLocation.MUTATION,
|
@@ -3295,10 +3306,8 @@ function getReachableTypes(schema16) {
|
|
3295
3306
|
for (let node of schema16.getDirectives())
|
3296
3307
|
if (node.locations.some((location) => RequestDirectiveLocations.has(location))) {
|
3297
3308
|
reachableTypes.add(node.name);
|
3298
|
-
for (let arg of node.args)
|
3299
|
-
|
3300
|
-
argTypeName && reachableTypes.add(argTypeName);
|
3301
|
-
}
|
3309
|
+
for (let arg of node.args)
|
3310
|
+
reachableTypes.add(getNamedType(arg.type).name);
|
3302
3311
|
}
|
3303
3312
|
return reachableTypesCache.set(schema16, reachableTypes), reachableTypes;
|
3304
3313
|
}
|
@@ -3600,7 +3609,7 @@ var rule16 = {
|
|
3600
3609
|
};
|
3601
3610
|
|
3602
3611
|
// src/rules/relay-arguments/index.ts
|
3603
|
-
import { isScalarType as isScalarType2, Kind as
|
3612
|
+
import { isScalarType as isScalarType2, Kind as Kind13 } from "graphql";
|
3604
3613
|
var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", schema9 = {
|
3605
3614
|
type: "array",
|
3606
3615
|
maxItems: 1,
|
@@ -3674,7 +3683,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3674
3683
|
return {
|
3675
3684
|
"FieldDefinition > .gqlType Name[value=/Connection$/]"(node) {
|
3676
3685
|
let fieldNode = node.parent;
|
3677
|
-
for (; fieldNode.kind !==
|
3686
|
+
for (; fieldNode.kind !== Kind13.FIELD_DEFINITION; )
|
3678
3687
|
fieldNode = fieldNode.parent;
|
3679
3688
|
let args = Object.fromEntries(
|
3680
3689
|
fieldNode.arguments?.map((argument) => [argument.name.value, argument]) || []
|
@@ -3688,7 +3697,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3688
3697
|
}
|
3689
3698
|
function checkField(typeName, argumentName) {
|
3690
3699
|
let argument = args[argumentName], hasArgument = !!argument, type = argument;
|
3691
|
-
if (hasArgument && type.gqlType.kind ===
|
3700
|
+
if (hasArgument && type.gqlType.kind === Kind13.NON_NULL_TYPE && (type = type.gqlType), !(hasArgument && type.gqlType.kind === Kind13.NAMED_TYPE && (type.gqlType.name.value === typeName || typeName === "String" && isScalarType2(schema16.getType(type.gqlType.name.value))))) {
|
3692
3701
|
let returnType = typeName === "String" ? "String or Scalar" : typeName;
|
3693
3702
|
context.report({
|
3694
3703
|
node: (argument || fieldNode).name,
|
@@ -3703,17 +3712,17 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
|
|
3703
3712
|
};
|
3704
3713
|
|
3705
3714
|
// src/rules/relay-connection-types/index.ts
|
3706
|
-
import { Kind as
|
3715
|
+
import { Kind as Kind14 } from "graphql";
|
3707
3716
|
var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES", MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO", MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX", EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE", PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE", NON_OBJECT_TYPES = [
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
+
Kind14.SCALAR_TYPE_DEFINITION,
|
3718
|
+
Kind14.UNION_TYPE_DEFINITION,
|
3719
|
+
Kind14.UNION_TYPE_EXTENSION,
|
3720
|
+
Kind14.INPUT_OBJECT_TYPE_DEFINITION,
|
3721
|
+
Kind14.INPUT_OBJECT_TYPE_EXTENSION,
|
3722
|
+
Kind14.ENUM_TYPE_DEFINITION,
|
3723
|
+
Kind14.ENUM_TYPE_EXTENSION,
|
3724
|
+
Kind14.INTERFACE_TYPE_DEFINITION,
|
3725
|
+
Kind14.INTERFACE_TYPE_EXTENSION
|
3717
3726
|
], notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`, hasEdgesField = (node) => node.fields?.some((field) => field.name.value === "edges"), hasPageInfoField = (node) => node.fields?.some((field) => field.name.value === "pageInfo"), rule18 = {
|
3718
3727
|
meta: {
|
3719
3728
|
type: "problem",
|
@@ -3780,10 +3789,10 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
|
|
3780
3789
|
hasEdgesField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_EDGES }), hasPageInfoField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_PAGE_INFO });
|
3781
3790
|
},
|
3782
3791
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType"(node) {
|
3783
|
-
node.kind ===
|
3792
|
+
node.kind === Kind14.LIST_TYPE || node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.LIST_TYPE || context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
|
3784
3793
|
},
|
3785
3794
|
":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=pageInfo] > .gqlType"(node) {
|
3786
|
-
node.kind ===
|
3795
|
+
node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.NAMED_TYPE && node.gqlType.name.value === "PageInfo" || context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
|
3787
3796
|
}
|
3788
3797
|
};
|
3789
3798
|
}
|
@@ -3793,7 +3802,7 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
|
|
3793
3802
|
import {
|
3794
3803
|
isObjectType as isObjectType2,
|
3795
3804
|
isScalarType as isScalarType3,
|
3796
|
-
Kind as
|
3805
|
+
Kind as Kind15,
|
3797
3806
|
visit as visit7
|
3798
3807
|
} from "graphql";
|
3799
3808
|
import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
|
@@ -3888,7 +3897,7 @@ var schema10 = {
|
|
3888
3897
|
shouldImplementNode: !0,
|
3889
3898
|
listTypeCanWrapOnlyEdgeType: !0,
|
3890
3899
|
...context.options[0]
|
3891
|
-
}, isNamedOrNonNullNamed = (node) => node.kind ===
|
3900
|
+
}, isNamedOrNonNullNamed = (node) => node.kind === Kind15.NAMED_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.NAMED_TYPE, checkNodeField = (node) => {
|
3892
3901
|
let nodeField = node.fields?.find((field) => field.name.value === "node"), message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
|
3893
3902
|
if (!nodeField)
|
3894
3903
|
context.report({
|
@@ -3925,7 +3934,7 @@ var schema10 = {
|
|
3925
3934
|
}
|
3926
3935
|
};
|
3927
3936
|
return options.listTypeCanWrapOnlyEdgeType && (listeners["FieldDefinition > .gqlType"] = (node) => {
|
3928
|
-
if (node.kind ===
|
3937
|
+
if (node.kind === Kind15.LIST_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.LIST_TYPE) {
|
3929
3938
|
let typeName = getTypeName(node.rawNode());
|
3930
3939
|
edgeTypes.has(typeName) || context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
|
3931
3940
|
}
|
@@ -3934,7 +3943,7 @@ var schema10 = {
|
|
3934
3943
|
};
|
3935
3944
|
|
3936
3945
|
// src/rules/relay-page-info/index.ts
|
3937
|
-
import { isScalarType as isScalarType4, Kind as
|
3946
|
+
import { isScalarType as isScalarType4, Kind as Kind16 } from "graphql";
|
3938
3947
|
var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE2 = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`, hasPageInfoChecked = !1, rule20 = {
|
3939
3948
|
meta: {
|
3940
3949
|
type: "problem",
|
@@ -3990,7 +3999,7 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
|
|
3990
3999
|
let field = fieldMap[fieldName], isAllowedType = !1;
|
3991
4000
|
if (field) {
|
3992
4001
|
let type = field.gqlType;
|
3993
|
-
typeName === "Boolean" ? isAllowedType = type.kind ===
|
4002
|
+
typeName === "Boolean" ? isAllowedType = type.kind === Kind16.NON_NULL_TYPE && type.gqlType.kind === Kind16.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === Kind16.NAMED_TYPE && (isAllowedType = type.name.value === "String" || isScalarType4(schema16.getType(type.name.value)));
|
3994
4003
|
}
|
3995
4004
|
if (!isAllowedType) {
|
3996
4005
|
let returnType = typeName === "Boolean" ? "non-null Boolean" : "either String or Scalar, which can be null if there are no results";
|
@@ -4194,15 +4203,15 @@ var rule22 = {
|
|
4194
4203
|
};
|
4195
4204
|
|
4196
4205
|
// src/rules/require-description/index.ts
|
4197
|
-
import { Kind as
|
4206
|
+
import { Kind as Kind17, TokenKind as TokenKind3 } from "graphql";
|
4198
4207
|
import { getRootTypeNames } from "@graphql-tools/utils";
|
4199
4208
|
var RULE_ID14 = "require-description", ALLOWED_KINDS2 = [
|
4200
4209
|
...TYPES_KINDS,
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4210
|
+
Kind17.DIRECTIVE_DEFINITION,
|
4211
|
+
Kind17.FIELD_DEFINITION,
|
4212
|
+
Kind17.INPUT_VALUE_DEFINITION,
|
4213
|
+
Kind17.ENUM_VALUE_DEFINITION,
|
4214
|
+
Kind17.OPERATION_DEFINITION
|
4206
4215
|
], schema12 = {
|
4207
4216
|
type: "array",
|
4208
4217
|
minItems: 1,
|
@@ -4225,7 +4234,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4225
4234
|
...Object.fromEntries(
|
4226
4235
|
[...ALLOWED_KINDS2].sort().map((kind) => {
|
4227
4236
|
let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
|
4228
|
-
return kind ===
|
4237
|
+
return kind === Kind17.OPERATION_DEFINITION && (description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.'), [kind, { type: "boolean", description }];
|
4229
4238
|
})
|
4230
4239
|
)
|
4231
4240
|
}
|
@@ -4301,7 +4310,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4301
4310
|
configOptions: [
|
4302
4311
|
{
|
4303
4312
|
types: !0,
|
4304
|
-
[
|
4313
|
+
[Kind17.DIRECTIVE_DEFINITION]: !0,
|
4305
4314
|
rootField: !0
|
4306
4315
|
}
|
4307
4316
|
],
|
@@ -4327,7 +4336,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
4327
4336
|
}
|
4328
4337
|
return {
|
4329
4338
|
[[...kinds].join(",")](node) {
|
4330
|
-
let description = "", isOperation = node.kind ===
|
4339
|
+
let description = "", isOperation = node.kind === Kind17.OPERATION_DEFINITION;
|
4331
4340
|
if (isOperation) {
|
4332
4341
|
let rawNode = node.rawNode(), { prev, line } = rawNode.loc.startToken;
|
4333
4342
|
if (prev?.kind === TokenKind3.COMMENT) {
|
@@ -4533,7 +4542,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
|
|
4533
4542
|
};
|
4534
4543
|
|
4535
4544
|
// src/rules/require-nullable-fields-with-oneof/index.ts
|
4536
|
-
import { Kind as
|
4545
|
+
import { Kind as Kind18 } from "graphql";
|
4537
4546
|
var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
4538
4547
|
meta: {
|
4539
4548
|
type: "suggestion",
|
@@ -4577,11 +4586,11 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
|
4577
4586
|
return {
|
4578
4587
|
"Directive[name.value=oneOf]"({ parent }) {
|
4579
4588
|
if ([
|
4580
|
-
|
4581
|
-
|
4589
|
+
Kind18.OBJECT_TYPE_DEFINITION,
|
4590
|
+
Kind18.INPUT_OBJECT_TYPE_DEFINITION
|
4582
4591
|
].includes(parent.kind))
|
4583
4592
|
for (let field of parent.fields || [])
|
4584
|
-
field.gqlType.kind ===
|
4593
|
+
field.gqlType.kind === Kind18.NON_NULL_TYPE && context.report({
|
4585
4594
|
node: field.name,
|
4586
4595
|
messageId: RULE_ID17,
|
4587
4596
|
data: { nodeName: getNodeName(field) }
|
@@ -4592,7 +4601,7 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
|
|
4592
4601
|
};
|
4593
4602
|
|
4594
4603
|
// src/rules/require-nullable-result-in-root/index.ts
|
4595
|
-
import { Kind as
|
4604
|
+
import { Kind as Kind19 } from "graphql";
|
4596
4605
|
var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
4597
4606
|
meta: {
|
4598
4607
|
type: "suggestion",
|
@@ -4642,7 +4651,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
|
4642
4651
|
"ObjectTypeDefinition,ObjectTypeExtension"(node) {
|
4643
4652
|
if (rootTypeNames.has(node.name.value))
|
4644
4653
|
for (let field of node.fields || []) {
|
4645
|
-
if (field.gqlType.type !==
|
4654
|
+
if (field.gqlType.type !== Kind19.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind19.NAMED_TYPE)
|
4646
4655
|
continue;
|
4647
4656
|
let name = field.gqlType.gqlType.name.value, type = schema16.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
|
4648
4657
|
context.report({
|
@@ -4673,7 +4682,7 @@ import {
|
|
4673
4682
|
GraphQLInterfaceType,
|
4674
4683
|
GraphQLObjectType,
|
4675
4684
|
GraphQLUnionType,
|
4676
|
-
Kind as
|
4685
|
+
Kind as Kind20,
|
4677
4686
|
TypeInfo as TypeInfo3,
|
4678
4687
|
visit as visit8,
|
4679
4688
|
visitWithTypeInfo as visitWithTypeInfo3
|
@@ -4770,7 +4779,7 @@ Include it in your selection set{{ addition }}.`
|
|
4770
4779
|
let schema16 = requireGraphQLSchemaFromContext(RULE_ID19, context), siblings = requireSiblingsOperations(RULE_ID19, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = asArray(fieldName), selector = "SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new TypeInfo3(schema16);
|
4771
4780
|
function checkFragments(node) {
|
4772
4781
|
for (let selection of node.selections) {
|
4773
|
-
if (selection.kind !==
|
4782
|
+
if (selection.kind !== Kind20.FRAGMENT_SPREAD)
|
4774
4783
|
continue;
|
4775
4784
|
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4776
4785
|
if (!foundSpread)
|
@@ -4778,7 +4787,7 @@ Include it in your selection set{{ addition }}.`
|
|
4778
4787
|
let checkedFragmentSpreads = /* @__PURE__ */ new Set(), visitor = visitWithTypeInfo3(typeInfo, {
|
4779
4788
|
SelectionSet(node2, key, _parent) {
|
4780
4789
|
let parent = _parent;
|
4781
|
-
parent.kind ===
|
4790
|
+
parent.kind === Kind20.FRAGMENT_DEFINITION ? checkedFragmentSpreads.add(parent.name.value) : parent.kind !== Kind20.INLINE_FRAGMENT && checkSelections(
|
4782
4791
|
node2,
|
4783
4792
|
typeInfo.getType(),
|
4784
4793
|
selection.loc.start,
|
@@ -4797,10 +4806,10 @@ Include it in your selection set{{ addition }}.`
|
|
4797
4806
|
else if (rawType instanceof GraphQLUnionType)
|
4798
4807
|
for (let selection of node.selections) {
|
4799
4808
|
let types = rawType.getTypes();
|
4800
|
-
if (selection.kind ===
|
4809
|
+
if (selection.kind === Kind20.INLINE_FRAGMENT) {
|
4801
4810
|
let t = types.find((t2) => t2.name === selection.typeCondition.name.value);
|
4802
4811
|
t && checkFields(t);
|
4803
|
-
} else if (selection.kind ===
|
4812
|
+
} else if (selection.kind === Kind20.FRAGMENT_SPREAD) {
|
4804
4813
|
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4805
4814
|
if (!foundSpread) return;
|
4806
4815
|
let fragmentSpread = foundSpread.document, t = fragmentSpread.typeCondition.name.value === rawType.name ? rawType : types.find((t2) => t2.name === fragmentSpread.typeCondition.name.value);
|
@@ -4813,11 +4822,11 @@ Include it in your selection set{{ addition }}.`
|
|
4813
4822
|
return;
|
4814
4823
|
function hasIdField({ selections }) {
|
4815
4824
|
return selections.some((selection) => {
|
4816
|
-
if (selection.kind ===
|
4825
|
+
if (selection.kind === Kind20.FIELD)
|
4817
4826
|
return selection.alias && idNames.includes(selection.alias.value) ? !0 : idNames.includes(selection.name.value);
|
4818
|
-
if (selection.kind ===
|
4827
|
+
if (selection.kind === Kind20.INLINE_FRAGMENT)
|
4819
4828
|
return hasIdField(selection.selectionSet);
|
4820
|
-
if (selection.kind ===
|
4829
|
+
if (selection.kind === Kind20.FRAGMENT_SPREAD) {
|
4821
4830
|
let [foundSpread] = siblings.getFragment(selection.name.value);
|
4822
4831
|
if (foundSpread) {
|
4823
4832
|
let fragmentSpread = foundSpread.document;
|
@@ -4845,7 +4854,7 @@ Include it in your selection set{{ addition }}.`
|
|
4845
4854
|
desc: `Add \`${idName}\` selection`,
|
4846
4855
|
fix: (fixer) => {
|
4847
4856
|
let insertNode = node.selections[0];
|
4848
|
-
return insertNode = insertNode.kind ===
|
4857
|
+
return insertNode = insertNode.kind === Kind20.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode, fixer.insertTextBefore(insertNode, `${idName} `);
|
4849
4858
|
}
|
4850
4859
|
}))), context.report(problem);
|
4851
4860
|
}
|
@@ -4920,7 +4929,7 @@ var RULE_ID20 = "require-type-pattern-with-oneof", rule29 = {
|
|
4920
4929
|
};
|
4921
4930
|
|
4922
4931
|
// src/rules/selection-set-depth/index.ts
|
4923
|
-
import { Kind as
|
4932
|
+
import { Kind as Kind21 } from "graphql";
|
4924
4933
|
import depthLimit from "graphql-depth-limit";
|
4925
4934
|
var RULE_ID21 = "selection-set-depth", schema14 = {
|
4926
4935
|
type: "array",
|
@@ -5006,7 +5015,7 @@ var RULE_ID21 = "selection-set-depth", schema14 = {
|
|
5006
5015
|
"OperationDefinition, FragmentDefinition"(node) {
|
5007
5016
|
try {
|
5008
5017
|
let rawNode = node.rawNode(), fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [], document = {
|
5009
|
-
kind:
|
5018
|
+
kind: Kind21.DOCUMENT,
|
5010
5019
|
definitions: [rawNode, ...fragmentsInUse]
|
5011
5020
|
};
|
5012
5021
|
checkFn({
|
@@ -5050,7 +5059,7 @@ var RULE_ID21 = "selection-set-depth", schema14 = {
|
|
5050
5059
|
};
|
5051
5060
|
|
5052
5061
|
// src/rules/strict-id-in-types/index.ts
|
5053
|
-
import { Kind as
|
5062
|
+
import { Kind as Kind22 } from "graphql";
|
5054
5063
|
var RULE_ID22 = "strict-id-in-types", schema15 = {
|
5055
5064
|
type: "array",
|
5056
5065
|
maxItems: 1,
|
@@ -5179,7 +5188,7 @@ var RULE_ID22 = "strict-id-in-types", schema15 = {
|
|
5179
5188
|
return;
|
5180
5189
|
if (node.fields?.filter((field) => {
|
5181
5190
|
let fieldNode = field.rawNode(), isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value), isValidIdType = !1;
|
5182
|
-
return fieldNode.type.kind ===
|
5191
|
+
return fieldNode.type.kind === Kind22.NON_NULL_TYPE && fieldNode.type.type.kind === Kind22.NAMED_TYPE && (isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value)), isValidIdName && isValidIdType;
|
5183
5192
|
})?.length !== 1) {
|
5184
5193
|
let pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "", pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
|
5185
5194
|
context.report({
|
@@ -5195,7 +5204,7 @@ Accepted type${pluralTypesSuffix}: ${englishJoinWords(options.acceptedIdTypes)}.
|
|
5195
5204
|
};
|
5196
5205
|
|
5197
5206
|
// src/rules/unique-enum-value-names/index.ts
|
5198
|
-
import { Kind as
|
5207
|
+
import { Kind as Kind23 } from "graphql";
|
5199
5208
|
var rule32 = {
|
5200
5209
|
meta: {
|
5201
5210
|
type: "suggestion",
|
@@ -5239,7 +5248,7 @@ var rule32 = {
|
|
5239
5248
|
},
|
5240
5249
|
create(context) {
|
5241
5250
|
return {
|
5242
|
-
[[
|
5251
|
+
[[Kind23.ENUM_TYPE_DEFINITION, Kind23.ENUM_TYPE_EXTENSION].join(",")](node) {
|
5243
5252
|
let duplicates = node.values?.filter(
|
5244
5253
|
(item, index, array) => array.findIndex((v) => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index
|
5245
5254
|
);
|
@@ -5265,9 +5274,9 @@ var rule32 = {
|
|
5265
5274
|
|
5266
5275
|
// src/rules/unique-fragment-name/index.ts
|
5267
5276
|
import { relative as relative2 } from "node:path";
|
5268
|
-
import { Kind as
|
5277
|
+
import { Kind as Kind24 } from "graphql";
|
5269
5278
|
var RULE_ID23 = "unique-fragment-name", checkNode = (context, node, ruleId) => {
|
5270
|
-
let documentName = node.name.value, siblings = requireSiblingsOperations(ruleId, context), siblingDocuments = node.kind ===
|
5279
|
+
let documentName = node.name.value, siblings = requireSiblingsOperations(ruleId, context), siblingDocuments = node.kind === Kind24.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
|
5271
5280
|
let isSameName = f.document.name?.value === documentName, isSamePath = slash(f.filePath) === slash(filepath);
|
5272
5281
|
return isSameName && !isSamePath;
|
5273
5282
|
});
|