Open jvanderwee opened 1 month ago
Thanks for reporting this. I believe https://github.com/apollographql/apollo-kotlin-adapters/commit/d2ccdecd37bd2b25dfa74f1c472278b6757f6e7e might be the issue although it mostly changes writing BigDecimal
, not reading them.
Can you share your data builder code and fake resolver?
Data builder:
UserReferralQuery.Data(resolver = FakeApolloResolver()) {
userReferralTotal = buildReferralTotalType {
value = BigDecimal.valueOf(20)
currency = "GBP"
}
},
Fake resolver:
class FakeApolloResolver : FakeResolver {
private val delegate = DefaultFakeResolver(__Schema.all)
override fun resolveLeaf(context: FakeResolverContext): Any {
val fieldName = context.mergedField.type.rawType().name
return when (fieldName) {
"Decimal" -> BigDecimal.TEN
else -> delegate.resolveLeaf(context)
}
}
override fun resolveListSize(context: FakeResolverContext): Int {
return delegate.resolveListSize(context)
}
override fun resolveMaybeNull(context: FakeResolverContext): Boolean {
return delegate.resolveMaybeNull(context)
}
override fun resolveTypename(context: FakeResolverContext): String {
return delegate.resolveTypename(context)
}
override fun stableIdForObject(
obj: Map<String, Any?>,
mergedField: CompiledField,
): String? {
return delegate.stableIdForObject(obj, mergedField)
}
}
Thanks for this, I can reproduce. Will look into this
Fix is here, it'll require a new version of Apollo Kotlin. In the meantime, feel free to stay on Apollo Adapters 0.0.3
. Apologies for the inconvenience and thanks for catching this 🙏
When updating to 0.0.4 we get this exception thrown in tests using data builders for queries with BigDecimal fields: