I am using AWS amplify with graphql and appsync. When I do a standard list query, appsync includes deleted items in the list of items it returns.
What can I do to make it return only items that are not deleted?
I tried this query, but it throws an error:
query MyQuery($filter: ModelFrameFilterInput = {_deleted: {ne: true}}) {
listFrames(filter: $filter) {
items {
_deleted
name
id
}
}
}
Here is the error message:
"message": "Validation error of type BadValueForDefaultArg: Bad default value ObjectValue{objectFields=[ObjectField{name='_deleted', value=ObjectValue{objectFields=[ObjectField{name='ne', value=BooleanValue{value=true}}]}}]} for type ModelFrameFilterInput"
This is not yet supported
Look at this issue / feature request
There's a workaround suggested, adding the _deleted
in the filter input of the graphql schema.
input ModelTodoFilterInput {
id: ModelIDInput
name: ModelStringInput
description: ModelStringInput
and: [ModelTodoFilterInput]
or: [ModelTodoFilterInput]
not: ModelTodoFilterInput
_deleted: ModelBooleanInput
}
One thing you can do is to disable Conflict Resolver, if it's not necessary for you, "after deleting elements that are using ConflictResolution, they are not immediately deleted from the database. Instead, two flags are being added: _deleted
is set to true and _ttl
is set to expire the object in 30 days." see: Error "Conflict resolver rejects mutation." when Delete in Amplify
To disable it, run amplify update api
, and you will be prompt to a choice to disable conflict resolver
But if you are using DataStore, then it is must to enable conflict resolver. in that case, I don't know how to solve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With