aws / aws/aws-appsync-community
AppSync JavaScript Resolvers: No difference between undefined (void 0) and null
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Null and undefined in mutations have quite the different meaning, e.g.
1. Setting a field to null means removing the field from the database record.
2. Leaving a field undefined means not altering a database record.
In AppSync JS resolvers however, the following check is true (and is of course false for regular JS):
`void 0 === null`
So given an AppSync input like
`{ fieldA: 'foo', fieldB: null }`
the only way to check if a field is null or not passed at all is via
`Object.keys(input).includes(field)`
That was quite the surprise for me.
Sorry if this is a repost or I missed it in the docs, it seems so basic to me that surely someone must have stumbled across this?
Contributor guide
Research direction
No repository file or test is named. Start by reproducing the reported comparison in an AppSync JavaScript resolver with omitted and null mutation fields, then review the resolver and input-value documentation; the work is done when the behavior is either corrected or its documented resolution clearly distinguishes the two cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100