aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

How to filter out dynamodb _deleted results?

Open 0afcode opened this issue 3 years ago • 0 comments

In dynamo db, there is a system field called _deleted, that is used by DataStore component to filter soft deleted items. When running an AppSync query this field is not available in the filters, but it is available in the doc items list. How do you handle this? Example:

query MyQuery {
  listRateSheets(filter: {or: {customer_id: {
    contains: "ecd7ea05-05ba-40c0-a345-95beaddbf82a"}, 
    job_id: {contains: "3c8c8319-f491-42d1-9395-78e383339c4b"}}, 
    active_flag: {eq: true},
  	_deleted: {eq: null}
  }) {
    items {
      id
      name
      _deleted
    }
  }
}

and the error:

"message": "Validation error of type WrongType: argument 'filter' with value 'ObjectValue{objectFields=[ObjectField{name='or', value=ObjectValue{objectFields=[ObjectField{name='customer_id', value=ObjectValue{objectFields=[ObjectField{name='contains', value=StringValue{value='ecd7ea05-05ba-40c0-a345-95beaddbf82a'}}]}}, ObjectField{name='job_id', value=ObjectValue{objectFields=[ObjectField{name='contains', value=StringValue{value='3c8c8319-f491-42d1-9395-78e383339c4b'}}]}}]}}, ObjectField{name='active_flag', value=ObjectValue{objectFields=[ObjectField{name='eq', value=BooleanValue{value=true}}]}}, ObjectField{name='_deleted', value=ObjectValue{objectFields=[ObjectField{name='eq', value=NullValue{}}]}}]}' contains a field not in 'ModelRateSheetFilterInput': '_deleted' @ 'listRateSheets'"

0afcode avatar Feb 28 '22 21:02 0afcode