@@ -8,7 +8,6 @@ import type {
8
8
ObjectFieldNode ,
9
9
ObjectValueNode ,
10
10
ValueNode ,
11
- VariableDefinitionNode ,
12
11
} from '../../language/ast.js' ;
13
12
import { Kind } from '../../language/kinds.js' ;
14
13
import { print } from '../../language/printer.js' ;
@@ -40,17 +39,7 @@ import type { ValidationContext } from '../ValidationContext.js';
40
39
export function ValuesOfCorrectTypeRule (
41
40
context : ValidationContext ,
42
41
) : ASTVisitor {
43
- let variableDefinitions : { [ key : string ] : VariableDefinitionNode } = { } ;
44
-
45
42
return {
46
- OperationDefinition : {
47
- enter ( ) {
48
- variableDefinitions = { } ;
49
- } ,
50
- } ,
51
- VariableDefinition ( definition ) {
52
- variableDefinitions [ definition . variable . name . value ] = definition ;
53
- } ,
54
43
ListValue ( node ) {
55
44
// Note: TypeInfo will traverse into a list's item type, so look to the
56
45
// parent input type to check if it is a list.
@@ -84,13 +73,7 @@ export function ValuesOfCorrectTypeRule(
84
73
}
85
74
86
75
if ( type . isOneOf ) {
87
- validateOneOfInputObject (
88
- context ,
89
- node ,
90
- type ,
91
- fieldNodeMap ,
92
- variableDefinitions ,
93
- ) ;
76
+ validateOneOfInputObject ( context , node , type , fieldNodeMap ) ;
94
77
}
95
78
} ,
96
79
ObjectField ( node ) {
@@ -189,7 +172,6 @@ function validateOneOfInputObject(
189
172
node : ObjectValueNode ,
190
173
type : GraphQLInputObjectType ,
191
174
fieldNodeMap : Map < string , ObjectFieldNode > ,
192
- variableDefinitions : { [ key : string ] : VariableDefinitionNode } ,
193
175
) : void {
194
176
const keys = Array . from ( fieldNodeMap . keys ( ) ) ;
195
177
const isNotExactlyOneField = keys . length !== 1 ;
@@ -206,29 +188,12 @@ function validateOneOfInputObject(
206
188
207
189
const value = fieldNodeMap . get ( keys [ 0 ] ) ?. value ;
208
190
const isNullLiteral = ! value || value . kind === Kind . NULL ;
209
- const isVariable = value ?. kind === Kind . VARIABLE ;
210
191
211
192
if ( isNullLiteral ) {
212
193
context . reportError (
213
194
new GraphQLError ( `Field "${ type } .${ keys [ 0 ] } " must be non-null.` , {
214
195
nodes : [ node ] ,
215
196
} ) ,
216
197
) ;
217
- return ;
218
- }
219
-
220
- if ( isVariable ) {
221
- const variableName = value . name . value ;
222
- const definition = variableDefinitions [ variableName ] ;
223
- const isNullableVariable = definition . type . kind !== Kind . NON_NULL_TYPE ;
224
-
225
- if ( isNullableVariable ) {
226
- context . reportError (
227
- new GraphQLError (
228
- `Variable "$${ variableName } " must be non-nullable to be used for OneOf Input Object "${ type } ".` ,
229
- { nodes : [ node ] } ,
230
- ) ,
231
- ) ;
232
- }
233
198
}
234
199
}
0 commit comments