If you compare an argument of GQL type Int with data from DDB (of type N), the comparison is working only using double eq operator ==. Ie.:
// ctx.args.value is of type Int
function response(ctx) {
const item = ctx.result.item // Obtained from DDB ({ expectedValue: 12 })
if (ctx.args.value == item.expectedValue) {
// This branch is called if ctx.args.value = 12
}
if (ctx.args.value === item.expectedValue) {
// This branch is UNREACHABLE
}
}
Even though both values are the same and typeof returns number for both compared values, the underlaying another custom, proprietary, re-implementation of JavaScript does not recognise GQL Int variable and DDB Number attribute as same type.
If you compare an argument of GQL type
Int
with data from DDB (of typeN
), the comparison is working only using double eq operator==
. Ie.:Even though both values are the same and
typeof
returnsnumber
for both compared values, the underlaying another custom, proprietary, re-implementation of JavaScript does not recognise GQL Int variable and DDB Number attribute as same type.Bug reproduction
Here is a minimal reproducible bug demonstration: https://github.com/testuj-to/appsync-inexplicable-type-discrepancy