Describe the bug
Adding the @versioned directive to a model breaks syncing, resulting in no changes being saved to the cloud.
Versions:
CLI: 4.17.2
JS: "@aws-amplify/core": "^2.2.5",
"@aws-amplify/datastore": "^1.0.8",
"@aws-amplify/pubsub": "^1.3.3",
This model syncs perfectly:
type Ting
@model
@auth(rules: [{ allow: owner }, { allow: groups, groups: ["admins"] }]) {
id: ID!
createdAt: AWSDateTime
references: [String]
referencedBy: [String]
content: String!
access: [UserTing] @connection(keyName: "byUser", fields: ["id"])
}
But adding @versioned like this:
type Ting
@model
@versioned
@auth(rules: [{ allow: owner }, { allow: groups, groups: ["admins"] }]) {
id: ID!
createdAt: AWSDateTime
references: [String]
referencedBy: [String]
content: String!
access: [UserTing] @connection(keyName: "byUser", fields: ["id"])
}
Gives the error:
"Variable 'input' has coerced Null value for NonNull type 'Int!'"

on every Update, Create and Delete seems to work. But no updates.
There's no way to be sure from the error, but I assume this means that _version is not being updated properly either client or server side.
@versioned is not meant to be used with DataStore, that's a directive for older functionality. The sync enabled resolvers in AppSync handle object versioning automatically.
That was not clear in the docs, but sounds amazing. Thank you.
Hey @raelmiu, the documentation here does mention:
"_Do not use this directive when leveraging DataStore as the conflict detection and resolution features are automatically handled inside AppSync and are incompatible with the @versioned directive_"
I am going to close this issue for now. Please open a new issue if you have any related questions or concerns.
Most helpful comment
@versionedis not meant to be used with DataStore, that's a directive for older functionality. The sync enabled resolvers in AppSync handle object versioning automatically.