@@ -10,7 +10,7 @@ import (
10
10
11
11
func TestValidate_NoUnusedVariables_UsesAllVariables (t * testing.T ) {
12
12
testutil .ExpectPassesRule (t , graphql .NoUnusedVariablesRule , `
13
- query Foo ($a: String, $b: String, $c: String) {
13
+ query ($a: String, $b: String, $c: String) {
14
14
field(a: $a, b: $b, c: $c)
15
15
}
16
16
` )
@@ -91,11 +91,11 @@ func TestValidate_NoUnusedVariables_VariableUsedByRecursiveFragment(t *testing.T
91
91
}
92
92
func TestValidate_NoUnusedVariables_VariableNotUsed (t * testing.T ) {
93
93
testutil .ExpectFailsRule (t , graphql .NoUnusedVariablesRule , `
94
- query Foo ($a: String, $b: String, $c: String) {
94
+ query ($a: String, $b: String, $c: String) {
95
95
field(a: $a, b: $b)
96
96
}
97
97
` , []gqlerrors.FormattedError {
98
- testutil .RuleError (`Variable "$c" is never used.` , 2 , 41 ),
98
+ testutil .RuleError (`Variable "$c" is never used.` , 2 , 38 ),
99
99
})
100
100
}
101
101
func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed (t * testing.T ) {
@@ -104,8 +104,8 @@ func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed(t *testing.T) {
104
104
field(b: $b)
105
105
}
106
106
` , []gqlerrors.FormattedError {
107
- testutil .RuleError (`Variable "$a" is never used.` , 2 , 17 ),
108
- testutil .RuleError (`Variable "$c" is never used.` , 2 , 41 ),
107
+ testutil .RuleError (`Variable "$a" is never used in operation "Foo" .` , 2 , 17 ),
108
+ testutil .RuleError (`Variable "$c" is never used in operation "Foo" .` , 2 , 41 ),
109
109
})
110
110
}
111
111
func TestValidate_NoUnusedVariables_VariableNotUsedInFragments (t * testing.T ) {
@@ -127,7 +127,7 @@ func TestValidate_NoUnusedVariables_VariableNotUsedInFragments(t *testing.T) {
127
127
field
128
128
}
129
129
` , []gqlerrors.FormattedError {
130
- testutil .RuleError (`Variable "$c" is never used.` , 2 , 41 ),
130
+ testutil .RuleError (`Variable "$c" is never used in operation "Foo" .` , 2 , 41 ),
131
131
})
132
132
}
133
133
func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed2 (t * testing.T ) {
@@ -149,8 +149,8 @@ func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed2(t *testing.T) {
149
149
field
150
150
}
151
151
` , []gqlerrors.FormattedError {
152
- testutil .RuleError (`Variable "$a" is never used.` , 2 , 17 ),
153
- testutil .RuleError (`Variable "$c" is never used.` , 2 , 41 ),
152
+ testutil .RuleError (`Variable "$a" is never used in operation "Foo" .` , 2 , 17 ),
153
+ testutil .RuleError (`Variable "$c" is never used in operation "Foo" .` , 2 , 41 ),
154
154
})
155
155
}
156
156
func TestValidate_NoUnusedVariables_VariableNotUsedByUnreferencedFragment (t * testing.T ) {
@@ -165,7 +165,7 @@ func TestValidate_NoUnusedVariables_VariableNotUsedByUnreferencedFragment(t *tes
165
165
field(b: $b)
166
166
}
167
167
` , []gqlerrors.FormattedError {
168
- testutil .RuleError (`Variable "$b" is never used.` , 2 , 17 ),
168
+ testutil .RuleError (`Variable "$b" is never used in operation "Foo" .` , 2 , 17 ),
169
169
})
170
170
}
171
171
func TestValidate_NoUnusedVariables_VariableNotUsedByFragmentUsedByOtherOperation (t * testing.T ) {
@@ -183,7 +183,7 @@ func TestValidate_NoUnusedVariables_VariableNotUsedByFragmentUsedByOtherOperatio
183
183
field(b: $b)
184
184
}
185
185
` , []gqlerrors.FormattedError {
186
- testutil .RuleError (`Variable "$b" is never used.` , 2 , 17 ),
187
- testutil .RuleError (`Variable "$a" is never used.` , 5 , 17 ),
186
+ testutil .RuleError (`Variable "$b" is never used in operation "Foo" .` , 2 , 17 ),
187
+ testutil .RuleError (`Variable "$a" is never used in operation "Bar" .` , 5 , 17 ),
188
188
})
189
189
}
0 commit comments