File tree 2 files changed +28
-2
lines changed 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,33 @@ describe('Type System: Example', () => {
184
184
} ) ;
185
185
} ) ;
186
186
187
+ it ( 'defines an enum type with a value of `null` and `undefined`' , ( ) => {
188
+ const EnumTypeWithNullishValue = new GraphQLEnumType ( {
189
+ name : 'EnumWithNullishValue' ,
190
+ values : {
191
+ NULL : { value : null } ,
192
+ UNDEFINED : { value : undefined } ,
193
+ }
194
+ } ) ;
195
+
196
+ expect ( EnumTypeWithNullishValue . getValues ( ) ) . to . deep . equal ( [
197
+ {
198
+ name : 'NULL' ,
199
+ description : undefined ,
200
+ isDeprecated : false ,
201
+ deprecationReason : undefined ,
202
+ value : null ,
203
+ } ,
204
+ {
205
+ name : 'UNDEFINED' ,
206
+ description : undefined ,
207
+ isDeprecated : false ,
208
+ deprecationReason : undefined ,
209
+ value : undefined ,
210
+ } ,
211
+ ] ) ;
212
+ } ) ;
213
+
187
214
it ( 'defines an object type with deprecated field' , ( ) => {
188
215
const TypeWithDeprecatedField = new GraphQLObjectType ( {
189
216
name : 'foo' ,
Original file line number Diff line number Diff line change 9
9
*/
10
10
11
11
import invariant from '../jsutils/invariant' ;
12
- import isNullish from '../jsutils/isNullish' ;
13
12
import { ENUM } from '../language/kinds' ;
14
13
import { assertValidName } from '../utilities/assertValidName' ;
15
14
import type {
@@ -984,7 +983,7 @@ function defineEnumValues(
984
983
description : value . description ,
985
984
isDeprecated : Boolean ( value . deprecationReason ) ,
986
985
deprecationReason : value . deprecationReason ,
987
- value : isNullish ( value . value ) ? valueName : value . value ,
986
+ value : value . hasOwnProperty ( ' value' ) ? value . value : valueName ,
988
987
} ;
989
988
} ) ;
990
989
}
You can’t perform that action at this time.
0 commit comments