GraphQL API Attribute not removed when providing null
See original GitHub issueDescribe the bug
When doing an update mutation with a value of null (or undefined) for the key the attribute is not removed in DynamoDB.
To Reproduce Steps to reproduce the behavior: Create a model and push it and generate the graphql mutations
type Article @model
{
id: ID!
title: String
subtitle: String
}
Insert an article with a title and subtitle
Do an update mutation with a new title and set subtitle to null
graphqlOperation(mutations.updateArticle, {
input: { title: 'new title', subtitle: null },
})
The title is changed in DynamoDB but the subtitle is still there untouched
Expected behavior What was expected is that the attribute subtitle should be removed from the DynamoDB table. This is mentioned/documented on the AppSync docs
If the attribute is set to null, it asks AWS AppSync and DynamoDB to remove that attribute from the post object
When executing the query in the AppSync console the attribute was removed (as expected)
mutation UpdateArticle {
updateArticle(input: { id: "4f482b...", title: "new title", subtitle: null }) {
id
}
}
Also in the generated mutation resolver (generende with Amplify CLI) of the article there you see the line where it states when the value is null the key (attribute) should be removed
#if( $util.isNull($entry.value) )
#set( $discard = $expRemove.add("#$entry.key") )
$util.qr($expNames.put("#$entry.key", "$entry.key"))
Desktop:
- OS: MacOS X
- Browser Safari, Chrome, Firefox
- Latest version
Additional context Updated all amplify packages to latest with no effect, also tried to do it with the Appsync SDK and Client but no change; also with a own typed gql no change.
dependencies": {
"aws-amplify": "^1.1.18",
"aws-amplify-react": "^2.2.5",
"aws-appsync": "^1.7.0",
"graphql-tag": "^2.10.0",
"node-sass": "^4.11.0",
"npm": "^6.5.0",
"prop-types": "^15.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "^2.1.3"
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
The same thing happens on iOS app as well
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-helpchannels or Discussions for those types of questions.