question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Including _version in delete requests, unable to filter _deleted items from list response.

See original GitHub issue

Which Category is your question related to? Using AWS Amplify API to delete items through AWS Appsync

Amplify CLI Version 4.18.1

What AWS Services are you utilizing? AWS Appsync, DynamoDB

Provide additional details e.g. code snippets While using API.graphql to delete items from my database I have 2 following issue:

Issue # 1:

Here is my request to delete a photo from the frontend:

API.graphql(graphqlOperation(mutations.deletePhoto, {
      input: {
        id: photoId,
        _version: 1,
      }
    })) as unknown as {
      data: DeletePhotoMutation
    }

Currently, there’s no way for me delete an item without including the _version of the item without running into an error:

errorType: "ConflictUnhandled"
message: "Conflict resolver rejects mutation."

Is this intended? Or am I missing something.

Issue # 2 :

When I successfully deleted the item using the API by adding in the _version attributes, I verified that the deleted attributes in DynamoDB is false,

Screen Shot 2020-04-28 at 8 51 43 PM

When I list all the items again, I couldn’t find a way to filter out deleted items from server side. The generated types for the filter is like so:

export type ModelPhotoFilterInput = {
  id?: ModelIDInput | null,
  albumId?: ModelIDInput | null,
  bucket?: ModelStringInput | null,
  and?: Array< ModelPhotoFilterInput | null > | null,
  or?: Array< ModelPhotoFilterInput | null > | null,
  not?: ModelPhotoFilterInput | null,
};

So now I have to fetch all items from serverside and filter deleted items out on the front end like so

const listPhotosByAlbum = async (input: ListPhotosByAlbumQueryVariables): Promise<any> => {
  const response = await API.graphql(graphqlOperation(queries.listPhotosByAlbum, input)) as unknown as {
    data: ListPhotosByAlbumQuery
  };
  return response.data.listPhotosByAlbum.items.filter(item => item._deleted !== true);
};

which isn’t ideal considering the number of deleted items can grow indefinitely and slow down the response.

Appreciate if anyone can share their experience.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
jesper-bylundcommented, Apr 30, 2020

Same issue, shouldn’t Appsync Resolvers filter out _deleted=true ?

3reactions
LawrenceNormancommented, Jul 1, 2020

I have to agree with Mentioum & drixta, seems like an unnecessary pain to have filter out deleted items on the client side, and not enable a query of non-deleted items from the server. I’m running into this same issue, and it’s too bad that I can’t filter or do something to query out the _deleted items server side via : listBlogs(filter: {type: {notContains: “_deleted”}}), I guess I will look at creating my own field “trash”, move the item to the “trash”, delete it, and then filter it out non trash from my main queries, but that seems like lot of extra unnecessary steps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with delete markers - Amazon Simple Storage Service
The only way to list delete markers (and other versions of an object) is by using the versions subresource in a GET Bucket...
Read more >
List deletedItems (directory objects) - Microsoft Graph v1.0
Retrieve a list of recently deleted items from deleted items.
Read more >
Retrieve an Amazon S3 object that was deleted - AWS re:Post
I want to retrieve an object that was deleted from my Amazon Simple Storage Service (Amazon S3) bucket that has versioning enabled. How...
Read more >
Recorded Responses - Qualtrics
You can easily remove specific responses from your dataset. You can delete a single response, selected responses, or responses based on filters.
Read more >
JSON:API — Latest Specification (v1.1)
Extensions cannot alter or remove specification semantics, ... with the namespace version has specified a resource object member version:id ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found