They should be testable on their own and they should be reusable. Ideally, those parts should be designed in a way that does not couple them with each other. To build anything complicated, the one and only truly helpful strategy is to split what needs to be built into smaller parts and then focus on one part at a time. When we go to bookmarks and remove bookmark, it will get removed from the Bookmarks tab, as well as the Home tab.What are GraphQL fragments? What are UI components? Why are they a match? For the bookmark ID, we want to set this to null, because the bookmark for this story was just removed. This will be the story ID of the story that the bookmark belong to. In an object, the fields we want to pass in for the ID. We'll pass in the fragment we just created.
![graphql fragments graphql fragments](https://i.ytimg.com/vi/oTYe4oAaloo/maxresdefault.jpg)
#Graphql fragments update
We'll want to update the ID and the bookmark ID. This will be GraphQL tag, template strings, and fragment_on the story type. After this update query, we'll do if Story ID. We'll need to import the GraphQL tag from Urql. Once this update query has run, then this story ID should be populated with the ID of the story that was removed.
![graphql fragments graphql fragments](https://i.ytimg.com/vi/yqq0ruWnObA/maxresdefault.jpg)
We'll have to also query for the story and the ID of the story. This will find either the correct bookmark or null. Let's find the bookmark where the bookmark ID is args bookmark ID. In our update function, let's do story ID =. Otherwise, we'll need to know the story ID that this bookmark was for. In order to ensure this emoji disappears when the bookmark gets removed, we'll need to ensure that once a bookmark gets removed, then this bookmark ID in the story summary field gets set back to null. Let's add these two stories back to our bookmarks. However, when we head over to the home tab, the bookmark emoji is still being displayed here next to the title and only gets updated after we pull to refresh. When we remove the bookmark, it gets automatically removed from the bookmarks tab. We get the item and we'll only keep the items where the item ID is not equal to the args bookmark ID. Let's do data.bookmarks equals, and we'll do data bookmarks filter. Then we'll check if data.bookmarks is defined. In the update function, we'll get the data, which will be of type all-bookmarks query or null. We'll pass in the bookmarks query as before. As before, let's check whether the result, remove bookmark, returns true. The arguments will be of type, remove bookmark mutation variables. We'll know that the result of remove bookmark will be of type, remove bookmark mutation. Let's import the remove bookmark mutation and remove bookmark mutation variables from our generated types. This will return the result, args, and cache. Open app.tsx, and in the updates section, let's add one for remove bookmark. We'll need to implement the rest of the cache updates manually based on this result. This is because if we have a look at the remove bookmark mutation, it only returns a Boolean, true or false, for whether the bookmark was removed. Now we can remove a bookmark, but we still have to pull-to-refresh for it to actually get removed. Here, we'll pass in CTA = remove, because we want to show the Remove button. In the bookmark screen, let's scroll down to the story. Let's pass in CTA = add, because we want to show the Add button. On the home screen, let's scroll down to the render item. Finally, for the loading state, we want to show that if we're adding a bookmark or if we're removing one. The bookmark ID is going to be item bookmark ID. Here, we'll need to pass in the bookmark ID. On a pressable, pass in an on press prop.
![graphql fragments graphql fragments](https://cdn.shopify.com/s/files/1/0533/2089/files/graphql-fragments.jpg)
Then let's return a pressable with some text inside it saying, remove bookmark. Underneath it, let's check if there is a bookmark ID and we're not already removing a bookmark, and the CTA is-remove. In the render function, let's only display this Add Bookmark button if the CTA is add. Let's add another prop to a component called CTA. Remove bookmark mutation and remove bookmark mutation variables. We'll pass in to remove bookmark mutation. The second item in the array will be remove bookmark and it'll be useMutation. This will be an array and we can de-structure fetching as isRemoving bookmark.
![graphql fragments graphql fragments](https://atendesigngroup.com/sites/default/files/graphql-query-06.png)
Underneath the add bookmark mutation, add another constant. Import the newly generated remove bookmarks mutation, and the remove bookmarks mutation variables from our generated operation types. Let's paste the mutation inside, open the terminal, and regenerate the types. This will use the GraphQL tag and template strings. Open the story component and create a new constant called remove bookmark mutation. Instructor: From Insomnia, let's copy the mutation for removing a bookmark.