File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -68,11 +68,13 @@ public Object parseLiteral(Object input) {
6868
6969 public static GraphQLScalarType GraphQLFloat = new GraphQLScalarType ("Float" , "Built-in Float" , new Coercing () {
7070 @ Override
71- public Object serialize (Object input ) {
71+ public Float serialize (Object input ) {
7272 if (input instanceof String ) {
7373 return Float .parseFloat ((String ) input );
7474 } else if (input instanceof Float ) {
75- return input ;
75+ return (Float ) input ;
76+ } else if (input instanceof Integer ) {
77+ return (float ) (Integer ) input ;
7678 } else {
7779 return null ;
7880 }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class ScalarsTest extends Specification {
2727 value | result
2828 Boolean . FALSE | " false"
2929 " test" | " test"
30- null | null
30+ null | null
3131 }
3232
3333
@@ -48,7 +48,7 @@ class ScalarsTest extends Specification {
4848 where :
4949 value | result
5050 " 5457486ABSBHS4w646" | " 5457486ABSBHS4w646"
51- null | null
51+ null | null
5252 }
5353
5454 def " Long parse literal" () {
@@ -72,7 +72,7 @@ class ScalarsTest extends Specification {
7272 " 42" | 42
7373 new Long (42345784398534785l ) | 42345784398534785l
7474 new Integer (42 ) | 42
75- null | null
75+ null | null
7676 }
7777
7878
@@ -95,7 +95,7 @@ class ScalarsTest extends Specification {
9595 value | result
9696 " 42" | 42
9797 new Integer (42 ) | 42
98- null | null
98+ null | null
9999 }
100100
101101 def " Float parse literal" () {
@@ -117,7 +117,8 @@ class ScalarsTest extends Specification {
117117 " 42.3" | 42.3f
118118 " 42.0" | 42.0f
119119 new Float (42.3 ) | 42.3f
120- null | null
120+ 10 | 10.0f
121+ null | null
121122 }
122123
123124 def " Boolean parse literal" () {
@@ -141,7 +142,7 @@ class ScalarsTest extends Specification {
141142 " true" | true
142143 0 | false
143144 1 | true
144- null | null
145+ null | null
145146 }
146147
147148
You can’t perform that action at this time.
0 commit comments