In this video Emmanuel Henri adds the necessary code to update items with mutations into our GraphQL server and the Mongo database.
- [Instructor] The final mutation we need for our GraphQL…severs is to be able to delete data.…So let's add this mutation.…So, again, like we've done in the past, we need to first…add the mutation in our type mutations,…so let's go ahead and add a new one, and we'll call…deleteFriend, and we'll take an ID, and it needs…absolutely an ID, so that's why I've put…the exclamation point here.…And then we'll return a string this time, because once we…delete a friend, well, it's no longer a part of the database…so we shouldn't be returning the friend itself,…because it's no longer there, so if we did that,…it would give you a null answer.…
So let's return a message instead, that yes,…something has been deleted in our database.…So, once we're done with that, save,…and then we go into the resolvers.…And in the resolver, we'll create a brand new function,…just below the updateFriend.…So, on line 39, get a comma in there, and then return,…and then deleteFriend, which, again, takes root,…and the input this time is the ID.…
- Basic GraphQL schema
- Object types and fields
- Role of the resolver in GraphQL
- Scalar and enumeration types
- Using GraphQL tools
- Setting up persistence
- Adding new items with mutations
- Updating and deleting items with mutations
- Queries with arguments, aliases, and fragments
Skill Level Intermediate
GraphQL: Data Fetching with Relaywith Emmanuel Henri2h 28m Intermediate
1. Setup and Introduction
2. Types and Schemas
3. Setting Up Persistence
5. Queries in Depth
Next steps1m 8s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.