Skip to content

Commit bfb284b

Browse files
osibbakerman
authored andcommitted
Support coercing a BigInteger into an ID Scalar
1 parent 6c01c80 commit bfb284b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/graphql/Scalars.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ private String convertImpl(Object input) {
278278
if (input instanceof UUID) {
279279
return String.valueOf(input);
280280
}
281+
if (input instanceof BigInteger) {
282+
return String.valueOf(input);
283+
}
281284
return null;
282285

283286
}

src/test/groovy/graphql/ScalarsIDTest.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ class ScalarsIDTest extends Specification {
4242
Scalars.GraphQLID.getCoercing().parseValue(value) == result
4343

4444
where:
45-
value | result
46-
"123ab" | "123ab"
47-
123 | "123"
48-
123123123123123123L | "123123123123123123"
45+
value | result
46+
"123ab" | "123ab"
47+
123 | "123"
48+
123123123123123123L | "123123123123123123"
49+
new BigInteger("123123123123123123") | "123123123123123123"
4950
UUID.fromString("037ebc7a-f9b8-4d76-89f6-31b34a40e10b") | "037ebc7a-f9b8-4d76-89f6-31b34a40e10b"
5051
}
5152

0 commit comments

Comments
 (0)