Skip to content

Commit cda7929

Browse files
authored
aa (#2721)
1 parent 710a4bb commit cda7929

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

.changeset/popular-radios-sleep.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
fix `no-unreachable-types` to consider wrapped request directive argument types

packages/plugin/src/rules/no-unreachable-types/index.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ ruleTester.run('no-unreachable-types', rule, {
166166
type Query
167167
`,
168168
}),
169+
withSchema({
170+
name: 'should ignore types from directive arguments with request locations',
171+
code: /* GraphQL */ `
172+
scalar Scalar1
173+
scalar Scalar2
174+
scalar Scalar3
175+
scalar Scalar4
176+
scalar Scalar5
177+
scalar Scalar6
178+
directive @q(arg: Scalar1) on QUERY
179+
directive @w(arg: Scalar2!) on QUERY
180+
directive @e(arg: [Scalar3]) on QUERY
181+
directive @r(arg: [Scalar4!]) on QUERY
182+
directive @t(arg: [Scalar5]!) on QUERY
183+
directive @y(arg: [Scalar6!]!) on QUERY
184+
`,
185+
}),
169186
],
170187
invalid: [
171188
withSchema({

packages/plugin/src/rules/no-unreachable-types/index.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ASTNode,
33
ASTVisitor,
44
DirectiveLocation,
5+
getNamedType,
56
GraphQLSchema,
67
isInterfaceType,
78
Kind,
@@ -102,10 +103,7 @@ function getReachableTypes(schema: GraphQLSchema): ReachableTypes {
102103
if (node.locations.some(location => RequestDirectiveLocations.has(location))) {
103104
reachableTypes.add(node.name);
104105
for (const arg of node.args) {
105-
const argTypeName = 'name' in arg.type && arg.type.name;
106-
if (argTypeName) {
107-
reachableTypes.add(argTypeName);
108-
}
106+
reachableTypes.add(getNamedType(arg.type).name);
109107
}
110108
}
111109
}

0 commit comments

Comments
 (0)