Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS amplify graphql appsync - do not return deleted items?

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"
like image 780
BitFunny Avatar asked Nov 14 '22 19:11

BitFunny


2 Answers

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
}
like image 66
BrunoLoops Avatar answered Dec 23 '22 13:12

BrunoLoops


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.

like image 25
jd11 Avatar answered Dec 23 '22 11:12

jd11