aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

[JS] Triple eq comparison not working for data from DDB #346

Closed patrik-simunic-cz closed 5 months ago

patrik-simunic-cz commented 7 months ago

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.

Bug reproduction

Here is a minimal reproducible bug demonstration: https://github.com/testuj-to/appsync-inexplicable-type-discrepancy

gilbertw1 commented 7 months ago

Thanks for reporting this, we'll look into it.

gilbertw1 commented 5 months ago

This issue has been resolved, please let us know if you run into any further problems.