@graphql-eslint/eslint-plugin 2.3.2-alpha-5f59ef8.0 → 2.3.2-alpha-759bc9e.0
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/index.js +18 -16
- package/index.mjs +18 -16
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1126,7 +1126,7 @@ const rule$5 = {
|
|
1126
1126
|
'[description.type="StringValue"]': node => {
|
1127
1127
|
if (node.description.block !== (style === 'block')) {
|
1128
1128
|
context.report({
|
1129
|
-
|
1129
|
+
node: node.description,
|
1130
1130
|
message: `Unexpected ${wrongDescriptionType} description`,
|
1131
1131
|
});
|
1132
1132
|
}
|
@@ -2516,17 +2516,15 @@ const rule$h = {
|
|
2516
2516
|
},
|
2517
2517
|
create(context) {
|
2518
2518
|
return {
|
2519
|
-
Directive(node) {
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
});
|
2529
|
-
}
|
2519
|
+
'Directive[name.value=deprecated]'(node) {
|
2520
|
+
const args = node.arguments || [];
|
2521
|
+
const reasonArg = args.find(arg => arg.name && arg.name.value === 'reason');
|
2522
|
+
const value = reasonArg ? String(valueFromNode(reasonArg.value) || '').trim() : null;
|
2523
|
+
if (!value) {
|
2524
|
+
context.report({
|
2525
|
+
loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
|
2526
|
+
message: 'Directive "@deprecated" must have a reason!',
|
2527
|
+
});
|
2530
2528
|
}
|
2531
2529
|
},
|
2532
2530
|
};
|
@@ -2683,18 +2681,22 @@ const rule$j = {
|
|
2683
2681
|
if (!mutationType || !queryType) {
|
2684
2682
|
return {};
|
2685
2683
|
}
|
2686
|
-
const selector =
|
2684
|
+
const selector = [
|
2685
|
+
`:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
|
2686
|
+
'>',
|
2687
|
+
graphql.Kind.FIELD_DEFINITION,
|
2688
|
+
graphql.Kind.NAMED_TYPE,
|
2689
|
+
].join(' ');
|
2687
2690
|
return {
|
2688
2691
|
[selector](node) {
|
2689
|
-
const
|
2690
|
-
const typeName = getTypeName(rawNode);
|
2692
|
+
const typeName = node.name.value;
|
2691
2693
|
const graphQLType = schema.getType(typeName);
|
2692
2694
|
if (graphql.isObjectType(graphQLType)) {
|
2693
2695
|
const { fields } = graphQLType.astNode;
|
2694
2696
|
const hasQueryType = fields.some(field => getTypeName(field) === queryType.name);
|
2695
2697
|
if (!hasQueryType) {
|
2696
2698
|
context.report({
|
2697
|
-
node,
|
2699
|
+
loc: getLocation(node.loc, typeName),
|
2698
2700
|
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}".`,
|
2699
2701
|
});
|
2700
2702
|
}
|
package/index.mjs
CHANGED
@@ -1120,7 +1120,7 @@ const rule$5 = {
|
|
1120
1120
|
'[description.type="StringValue"]': node => {
|
1121
1121
|
if (node.description.block !== (style === 'block')) {
|
1122
1122
|
context.report({
|
1123
|
-
|
1123
|
+
node: node.description,
|
1124
1124
|
message: `Unexpected ${wrongDescriptionType} description`,
|
1125
1125
|
});
|
1126
1126
|
}
|
@@ -2510,17 +2510,15 @@ const rule$h = {
|
|
2510
2510
|
},
|
2511
2511
|
create(context) {
|
2512
2512
|
return {
|
2513
|
-
Directive(node) {
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
});
|
2523
|
-
}
|
2513
|
+
'Directive[name.value=deprecated]'(node) {
|
2514
|
+
const args = node.arguments || [];
|
2515
|
+
const reasonArg = args.find(arg => arg.name && arg.name.value === 'reason');
|
2516
|
+
const value = reasonArg ? String(valueFromNode(reasonArg.value) || '').trim() : null;
|
2517
|
+
if (!value) {
|
2518
|
+
context.report({
|
2519
|
+
loc: getLocation(node.loc, node.name.value, { offsetEnd: 0 }),
|
2520
|
+
message: 'Directive "@deprecated" must have a reason!',
|
2521
|
+
});
|
2524
2522
|
}
|
2525
2523
|
},
|
2526
2524
|
};
|
@@ -2677,18 +2675,22 @@ const rule$j = {
|
|
2677
2675
|
if (!mutationType || !queryType) {
|
2678
2676
|
return {};
|
2679
2677
|
}
|
2680
|
-
const selector =
|
2678
|
+
const selector = [
|
2679
|
+
`:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
|
2680
|
+
'>',
|
2681
|
+
Kind.FIELD_DEFINITION,
|
2682
|
+
Kind.NAMED_TYPE,
|
2683
|
+
].join(' ');
|
2681
2684
|
return {
|
2682
2685
|
[selector](node) {
|
2683
|
-
const
|
2684
|
-
const typeName = getTypeName(rawNode);
|
2686
|
+
const typeName = node.name.value;
|
2685
2687
|
const graphQLType = schema.getType(typeName);
|
2686
2688
|
if (isObjectType$1(graphQLType)) {
|
2687
2689
|
const { fields } = graphQLType.astNode;
|
2688
2690
|
const hasQueryType = fields.some(field => getTypeName(field) === queryType.name);
|
2689
2691
|
if (!hasQueryType) {
|
2690
2692
|
context.report({
|
2691
|
-
node,
|
2693
|
+
loc: getLocation(node.loc, typeName),
|
2692
2694
|
message: `Mutation result type "${graphQLType.name}" must contain field of type "${queryType.name}".`,
|
2693
2695
|
});
|
2694
2696
|
}
|
package/package.json
CHANGED