In this video Emmanuel Henri adds the necessary code to update items with mutations in the GraphQL server and the Mongo database.
- [Manny] In this scenario where you need to…update items in the database with GraphQL,…we also need to set up the proper mutation to do so.…Let's get to it.…So, the first thing we need to do is open schema.js.…So, if you don't have it open,…go ahead and click on schema, like so.…And then, exactly here, in the type Mutation,…we need to create a new Mutation,…and this one we'll call updateFriend.…And the input is going to be exactly the same thing,…so input FriendInput,…and then, we return a Friend, as simple as that.…
So then, what we need to do is get into our resolvers,…so make sure you save that before you switch to resolvers.…And switch the resolver, and then,…just below the createFriend,…so let's make sure we are adding something here.…So on line 31, press Enter,…and then we're going to create the resolver…for Mongo to update a specific Friend.…So, as you may have guessed,…a specific Friend takes an input,…like we've done for adding a new Friend,…so we start with a root, and then we run a function.…
So, inside of that function,…
- 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.