You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
8.1.4
Amplify CLI Version
7.6.5
What operating system are you using?
Mac
Amplify Codegen Command
codegen, codegen models
Describe the bug
_version attribute is added by AppSync resolvers when a new record is created. This enables conflict resolution (optimistic locking).
However, when Amplify generates the model types from schema.graphql, _version attribute is not declared on the model type. ModelInput object expects _version when performing updates as one would expect, but the fact that the model object returned by the query doesn't formally declare the attribute means that you cannot provide all of the required inputs to the update mutation.
Expected behavior
_version should be declared on the auto-generated model type, or there should be another way to retrieve the record _version.
Reproduction steps
amplify configure codegen - Follow prompts to select TypeScript
Add the following definition to schema.graphql
typeTodo@model
{
id: ID!description: String
}
amplify codegen
At this point you should have a Todo type that doesn't have the _version attribute, and a TodoInput type that does have _version attribute.
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
8.1.4
Amplify CLI Version
7.6.5
What operating system are you using?
Mac
Amplify Codegen Command
codegen, codegen models
Describe the bug
_version attribute is added by AppSync resolvers when a new record is created. This enables conflict resolution (optimistic locking).
However, when Amplify generates the model types from schema.graphql, _version attribute is not declared on the model type. ModelInput object expects _version when performing updates as one would expect, but the fact that the model object returned by the query doesn't formally declare the attribute means that you cannot provide all of the required inputs to the update mutation.
Expected behavior
_version should be declared on the auto-generated model type, or there should be another way to retrieve the record _version.
Reproduction steps
amplify configure codegen
- Follow prompts to select TypeScriptamplify codegen
At this point you should have a Todo type that doesn't have the
_version
attribute, and a TodoInput type that does have_version
attribute.In src/models/index.d.ts:
In src/API.ts:
When I try to access the _version, I get a TypeScript compile warning:
GraphQL schema(s)
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: