File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ describe('valueFromAST', () => {
72
72
expectValueFrom ( '"BLUE"' , testEnum ) . to . equal ( undefined ) ;
73
73
expectValueFrom ( 'null' , testEnum ) . to . equal ( null ) ;
74
74
expectValueFrom ( 'NULL' , testEnum ) . to . equal ( null ) ;
75
+ expectValueFrom ( 'NULL' , new GraphQLNonNull ( testEnum ) ) . to . equal ( null ) ;
75
76
expectValueFrom ( 'NAN' , testEnum ) . to . deep . equal ( NaN ) ;
76
77
expectValueFrom ( 'NO_CUSTOM_VALUE' , testEnum ) . to . equal ( 'NO_CUSTOM_VALUE' ) ;
77
78
} ) ;
@@ -184,6 +185,7 @@ describe('valueFromAST', () => {
184
185
expectValueFrom ( '$var' , GraphQLBoolean , { } ) . to . equal ( undefined ) ;
185
186
expectValueFrom ( '$var' , GraphQLBoolean , { var : true } ) . to . equal ( true ) ;
186
187
expectValueFrom ( '$var' , GraphQLBoolean , { var : null } ) . to . equal ( null ) ;
188
+ expectValueFrom ( '$var' , nonNullBool , { var : null } ) . to . equal ( undefined ) ;
187
189
} ) ;
188
190
189
191
it ( 'asserts variables are provided as items in lists' , ( ) => {
Original file line number Diff line number Diff line change @@ -50,18 +50,6 @@ export function valueFromAST(
50
50
return ;
51
51
}
52
52
53
- if ( isNonNullType ( type ) ) {
54
- if ( valueNode . kind === Kind . NULL ) {
55
- return ; // Invalid: intentionally return no value.
56
- }
57
- return valueFromAST ( valueNode , type . ofType , variables ) ;
58
- }
59
-
60
- if ( valueNode . kind === Kind . NULL ) {
61
- // This is explicitly returning the value null.
62
- return null ;
63
- }
64
-
65
53
if ( valueNode . kind === Kind . VARIABLE ) {
66
54
const variableName = valueNode . name . value ;
67
55
if ( ! variables || isInvalid ( variables [ variableName ] ) ) {
@@ -78,6 +66,18 @@ export function valueFromAST(
78
66
return variableValue ;
79
67
}
80
68
69
+ if ( isNonNullType ( type ) ) {
70
+ if ( valueNode . kind === Kind . NULL ) {
71
+ return ; // Invalid: intentionally return no value.
72
+ }
73
+ return valueFromAST ( valueNode , type . ofType , variables ) ;
74
+ }
75
+
76
+ if ( valueNode . kind === Kind . NULL ) {
77
+ // This is explicitly returning the value null.
78
+ return null ;
79
+ }
80
+
81
81
if ( isListType ( type ) ) {
82
82
const itemType = type . ofType ;
83
83
if ( valueNode . kind === Kind . LIST ) {
You can’t perform that action at this time.
0 commit comments