Closed Bryson14 closed 1 year ago
Hi @Bryson14, it is expected that the API.graphql
call would not work without _version
passed when conflict resolution is enabled. However, the error you get from DataStore.delete
is unusual.
The error would indicate that Booking
passed in DataStore.delete
is not a model constructor. What is odd is that this case should be detected and throw a different error.
Is Booking
imported like import { Booking } from './models';
?
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.
Thank you!
For what it's worth, I was unable to reproduce the issue with the given reproduction steps. I was able to delete records by querying a record and passing the model to DataStore.delete.
Example:
const deleteTodo= async () => {
try {
const toDelete = (await DataStore.query(
Todo,
"385cd611-8e2e-40d1-9e6d-09dae7cce754"
)) as Todo;
const deletedTodo= await DataStore.delete(toDelete);
console.log({ deletedTodo });
} catch (error) {
console.log(error);
}
};
Intentionally querying for a record with an invalid id, resulting in an undefined
value passed to DataStore.delete(Todo, <invalid-id>)
throws the following error:
For the namespace resolver error, upgrading to the latest version of aws-amplify
should resolve that issue. If you haven't already done so, please try upgrading and let us know if the issue persists.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API, DataStore
Amplify Categories
auth, api
Environment information
Describe the bug
i have one object
Booking
that I am trying to delete which has relation keys to two other modelsTutor
andClient
:When I try to delete the booking model using
await Datastore.delete(Booking, bookingId);
. I get a failure of object not found:When I try to delete uing the GraphQL API, I get a similar conflicting error:
There is some sort of conflict that is happening behind the scenes. After a bit of investigating, I found that I can pass the _version of the model to the GraphQL API and get the model to delete.
Now changing the code to this, the model was deleted successfully from the database.
Expected behavior
I expect that calling
DataStore.delete()
should work as intended and should pass the _version to its AppSync API backend also.Reproduction steps
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response