@@ -2,10 +2,17 @@ import { ParserOptionsForTests, ruleTester } from '../../../__tests__/test-utils
2
2
import { rule } from './index.js' ;
3
3
4
4
const TEST_SCHEMA = /* GraphQL */ `
5
+ input TestInput {
6
+ a: Int @deprecated(reason: "Use 'b' instead.")
7
+ b: Boolean
8
+ }
9
+
5
10
type Query {
6
11
oldField: String @deprecated
7
12
oldFieldWithReason: String @deprecated(reason: "test")
8
13
newField: String!
14
+ testArgument(a: Int @deprecated(reason: "Use 'b' instead."), b: Boolean): Boolean
15
+ testObjectField(input: TestInput): Boolean
9
16
}
10
17
11
18
type Mutation {
@@ -29,7 +36,7 @@ const WITH_SCHEMA = {
29
36
30
37
ruleTester . run ( 'no-deprecated' , rule , {
31
38
valid : [
32
- { ...WITH_SCHEMA , code : 'query { newField }' } ,
39
+ { ...WITH_SCHEMA , code : '{ newField }' } ,
33
40
{ ...WITH_SCHEMA , code : 'mutation { something(t: NEW) }' } ,
34
41
] ,
35
42
invalid : [
@@ -39,7 +46,7 @@ ruleTester.run('no-deprecated', rule, {
39
46
errors : [
40
47
{
41
48
message :
42
- 'This enum value is marked as deprecated in your GraphQL schema (reason: No longer supported)' ,
49
+ 'Enum "OLD" is marked as deprecated in your GraphQL schema (reason: No longer supported)' ,
43
50
} ,
44
51
] ,
45
52
} ,
@@ -48,25 +55,49 @@ ruleTester.run('no-deprecated', rule, {
48
55
code : 'mutation { something(t: OLD_WITH_REASON) }' ,
49
56
errors : [
50
57
{
51
- message : 'This enum value is marked as deprecated in your GraphQL schema (reason: test)' ,
58
+ message :
59
+ 'Enum "OLD_WITH_REASON" is marked as deprecated in your GraphQL schema (reason: test)' ,
60
+ } ,
61
+ ] ,
62
+ } ,
63
+ {
64
+ ...WITH_SCHEMA ,
65
+ code : '{ oldField }' ,
66
+ errors : [
67
+ {
68
+ message :
69
+ 'Field "oldField" is marked as deprecated in your GraphQL schema (reason: No longer supported)' ,
70
+ } ,
71
+ ] ,
72
+ } ,
73
+ {
74
+ ...WITH_SCHEMA ,
75
+ code : '{ oldFieldWithReason }' ,
76
+ errors : [
77
+ {
78
+ message :
79
+ 'Field "oldFieldWithReason" is marked as deprecated in your GraphQL schema (reason: test)' ,
52
80
} ,
53
81
] ,
54
82
} ,
55
83
{
56
84
...WITH_SCHEMA ,
57
- code : 'query { oldField }' ,
85
+ code : '{ testArgument(a: 2) }' ,
58
86
errors : [
59
87
{
60
88
message :
61
- 'This field is marked as deprecated in your GraphQL schema (reason: No longer supported )' ,
89
+ 'Argument "a" is marked as deprecated in your GraphQL schema (reason: Use \'b\' instead. )' ,
62
90
} ,
63
91
] ,
64
92
} ,
65
93
{
66
94
...WITH_SCHEMA ,
67
- code : 'query { oldFieldWithReason }' ,
95
+ code : '{ testObjectField(input: { a: 2 }) }' ,
68
96
errors : [
69
- { message : 'This field is marked as deprecated in your GraphQL schema (reason: test)' } ,
97
+ {
98
+ message :
99
+ 'Object field "a" is marked as deprecated in your GraphQL schema (reason: Use \'b\' instead.)' ,
100
+ } ,
70
101
] ,
71
102
} ,
72
103
] ,
0 commit comments