-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_version field not getting added when using amplify pull #3770
Comments
Hi @amruth-movano , The To update a model using the Amplify API plugin, you should use the |
Yes @5d |
Hi @amruth-movano , The |
Actually we want using Amplify API query to create & update the rows. So one row for exercise table, the data can be updated multiple times. So to update the particular row for n number of times we need the version to pass to updatemutation query. So do we have any idea how can we get the version for a row in dynamodb to update it @5d ? |
Hi @amruth-movano , Thank you for the information. In the Amplify library, the However, if you use the API plugin, you will need to handle this metadata manually. Rather than utilizing the convenient APIs we designed for quickly creating a For example, in your case of updating a model instance, you should:
|
Hi @5d let dataQ = try await Amplify.API.query(request: .query(modelName: ActivityIntensity.modelName, byId: "7BBD68F6-64E2-4507-A792-9E6BCC64FFDE")) Received output => So now main thing is for some tables we don’t have ID primary field in table instead of that we have start_time/data_timestamp field which is primary key. So how should we use start_time/data_timestamp to fetch that element with version. Also our backend needs to pass the userId as well with the query. And one more question, can we fetch version in list query? Ex; Amplify.API.query(request: .list) |
@5d Can you please guide us in this scenario? |
@amruth-movano I will take a look at your query and try to get an answer for your question. Appreciate your patience on this. |
@harsh62 Yes please take a look and let us know the solution, as it's a blocker for us. |
Starting off with the last question first:
Yes, you should be able to do it.
Your start_time becomes the
You are missing a backslash
You should be able to use predicates to query data. https://docs.amplify.aws/gen1/swift/build-a-backend/graphqlapi/query-data/ Hope these answers your question. |
Hi @harsh62 let dataQuery = try await Amplify.API.query(request: .get(ExerciseSession2.self, byId: startTime.temporalDateTime.iso8601String)) Error - And for list query getting error there is no field called syncMetadata |
Are you able to use a predicate to pass both the fields?
|
@harsh62 if we pass through predicate also, it is giving same error as our backend needs userID directly & not from the predicate, so we are ovverriding it directly |
@harsh62 Can you give me a example to fetch version from list query? This will be easy for me if you can guide me in list query |
@amruth-movano I will work on drafting a query and provide an update soon. |
@harsh62 Yes, please. We will be waiting for your response |
@harsh62 Is there any update? |
Hi @amruth-movano , When working with a model schema with composite key, you have two options to access the composite identifier. Firstly, you could utilize the computed property Alternatively, you can build a composite key by specifying the values of the individual properties that make up the composite key, which might look something like this [ref]:
|
Describe the bug
I want to update the model using Amplify.API.Query(request.update),
But when i update a model I am getting error -
GraphQLResponseError: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Conflict resolver rejects mutation.", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: Optional([Amplify.JSONValue.string("updateExerciseSession2")]), extensions: Optional(["errorType": Amplify.JSONValue.string("ConflictUnhandled"), "errorInfo": Amplify.JSONValue.null, "data": Amplify.JSONValue.object(["createdAt": Amplify.JSONValue.string("2024-07-03T15:24:01.148Z"),"owner": Amplify.JSONValue.null, "__typename": Amplify.JSONValue.string("ExerciseSession2"), "updatedAt": Amplify.JSONValue.string("2024-07-03T15:24:01.148Z"), "user_id": Amplify.JSONValue.string("*******"), "start_time": Amplify.JSONValue.string("2024-07-03T15:23:59.055Z")])]))]
I think it is because we are not sending version but we don't have _version field in generated models.
Our model is like below -
extension ExerciseSession2 {
// MARK: - CodingKeys
enum CodingKeys: String, ModelKey {
case user_id
case start_time
case owner
case createdAt
case updatedAt
}
static let keys = CodingKeys.self
// MARK: - ModelSchema
static let schema = defineSchema { model in
let exerciseSession2 = ExerciseSession2.keys
}
Steps To Reproduce
Expected behavior
We should get version in generated schema
Amplify Framework Version
2.33.3
Amplify Categories
API, DataStore
Dependency manager
Swift PM
Swift version
5.9.2
CLI version
12.1.1
Xcode version
15.0
Relevant log output
No response
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
iOS 17.0
Device
iPhone 15 Plus
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: