File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,13 @@ const MAX_INT = 2147483647;
22
22
const MIN_INT = - 2147483648 ;
23
23
24
24
function serializeInt ( value : mixed ) : number {
25
- let num = value ;
25
+ if ( typeof value === 'boolean' ) {
26
+ return value ? 1 : 0 ;
27
+ }
28
+
29
+ const num = value ;
26
30
if ( typeof value === 'string' && value !== '' ) {
27
31
num = Number ( value ) ;
28
- } else if ( typeof value === 'boolean' ) {
29
- return value ? 1 : 0 ;
30
32
}
31
33
32
34
if ( ! isInteger ( num ) ) {
@@ -75,13 +77,14 @@ export const GraphQLInt = new GraphQLScalarType({
75
77
} ) ;
76
78
77
79
function serializeFloat ( value : mixed ) : number {
80
+ if ( typeof value === 'boolean' ) {
81
+ return value ? 1 : 0 ;
82
+ }
83
+
78
84
let num = value ;
79
85
if ( typeof value === 'string' && value !== '' ) {
80
86
num = Number ( value ) ;
81
- } else if ( typeof value === 'boolean' ) {
82
- return value ? 1 : 0 ;
83
87
}
84
-
85
88
if ( ! isFinite ( num ) ) {
86
89
throw new TypeError (
87
90
`Float cannot represent non numeric value: ${ inspect ( value ) } ` ,
You can’t perform that action at this time.
0 commit comments