1
1
import { didYouMean } from '../../jsutils/didYouMean.js' ;
2
2
import { inspect } from '../../jsutils/inspect.js' ;
3
- import { keyMap } from '../../jsutils/keyMap.js' ;
4
- import type { ObjMap } from '../../jsutils/ObjMap.js' ;
5
3
import { suggestionList } from '../../jsutils/suggestionList.js' ;
6
4
7
5
import { GraphQLError } from '../../error/GraphQLError.js' ;
@@ -186,10 +184,10 @@ function validateOneOfInputObject(
186
184
context : ValidationContext ,
187
185
node : ObjectValueNode ,
188
186
type : GraphQLInputObjectType ,
189
- fieldNodeMap : ObjMap < ObjectFieldNode > ,
187
+ fieldNodeMap : Map < string , ObjectFieldNode > ,
190
188
variableDefinitions : { [ key : string ] : VariableDefinitionNode } ,
191
189
) : void {
192
- const keys = Object . keys ( fieldNodeMap ) ;
190
+ const keys = Array . from ( fieldNodeMap . keys ( ) ) ;
193
191
const isNotExactlyOneField = keys . length !== 1 ;
194
192
195
193
if ( isNotExactlyOneField ) {
@@ -202,9 +200,9 @@ function validateOneOfInputObject(
202
200
return ;
203
201
}
204
202
205
- const value = fieldNodeMap [ keys [ 0 ] ] . value ;
206
- const isNullLiteral = value . kind === Kind . NULL ;
207
- const isVariable = value . kind === Kind . VARIABLE ;
203
+ const value = fieldNodeMap . get ( keys [ 0 ] ) ? .value ;
204
+ const isNullLiteral = ! value || value . kind === Kind . NULL ;
205
+ const isVariable = value ? .kind === Kind . VARIABLE ;
208
206
209
207
if ( isNullLiteral ) {
210
208
context . reportError (
0 commit comments