@graphql-eslint/eslint-plugin 3.16.1 → 3.16.2-alpha-20230316061943-b3c71ef
Sign up to get free protection for your applications and to get access to all the features.
@@ -98,17 +98,27 @@ const handleMissingFragments = ({ ruleId, context, node }) => {
|
|
98
98
|
};
|
99
99
|
const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasDidYouMeanSuggestions, }, docs) => {
|
100
100
|
let ruleFn = null;
|
101
|
+
const ruleKey = `${ruleName}Rule`;
|
101
102
|
try {
|
102
|
-
ruleFn = require(`graphql/validation/rules/${
|
103
|
+
ruleFn = require(`graphql/validation/rules/${ruleKey}`)[ruleKey];
|
103
104
|
}
|
104
105
|
catch (_a) {
|
105
106
|
try {
|
106
|
-
ruleFn = require(`graphql/validation/rules/${ruleName}`)[
|
107
|
+
ruleFn = require(`graphql/validation/rules/${ruleName}`)[ruleKey];
|
107
108
|
}
|
108
109
|
catch (_b) {
|
109
|
-
|
110
|
+
try {
|
111
|
+
ruleFn = require('graphql/validation')[ruleKey];
|
112
|
+
}
|
113
|
+
catch (_c) {
|
114
|
+
const { specifiedRules } = require('graphql');
|
115
|
+
ruleFn = specifiedRules.find((ruleFn) => ruleFn.name === ruleKey);
|
116
|
+
}
|
110
117
|
}
|
111
118
|
}
|
119
|
+
if (!ruleFn) {
|
120
|
+
throw new Error(`Failed to locate rule "${ruleName}" in "graphql-js" package!`);
|
121
|
+
}
|
112
122
|
return {
|
113
123
|
[ruleId]: {
|
114
124
|
meta: {
|
@@ -97,17 +97,27 @@ const handleMissingFragments = ({ ruleId, context, node }) => {
|
|
97
97
|
};
|
98
98
|
const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasDidYouMeanSuggestions, }, docs) => {
|
99
99
|
let ruleFn = null;
|
100
|
+
const ruleKey = `${ruleName}Rule`;
|
100
101
|
try {
|
101
|
-
ruleFn = require(`graphql/validation/rules/${
|
102
|
+
ruleFn = require(`graphql/validation/rules/${ruleKey}`)[ruleKey];
|
102
103
|
}
|
103
104
|
catch (_a) {
|
104
105
|
try {
|
105
|
-
ruleFn = require(`graphql/validation/rules/${ruleName}`)[
|
106
|
+
ruleFn = require(`graphql/validation/rules/${ruleName}`)[ruleKey];
|
106
107
|
}
|
107
108
|
catch (_b) {
|
108
|
-
|
109
|
+
try {
|
110
|
+
ruleFn = require('graphql/validation')[ruleKey];
|
111
|
+
}
|
112
|
+
catch (_c) {
|
113
|
+
const { specifiedRules } = require('graphql');
|
114
|
+
ruleFn = specifiedRules.find((ruleFn) => ruleFn.name === ruleKey);
|
115
|
+
}
|
109
116
|
}
|
110
117
|
}
|
118
|
+
if (!ruleFn) {
|
119
|
+
throw new Error(`Failed to locate rule "${ruleName}" in "graphql-js" package!`);
|
120
|
+
}
|
111
121
|
return {
|
112
122
|
[ruleId]: {
|
113
123
|
meta: {
|