In this video Emmanuel Henri discusses what is the role of the resolver in GraphQL and provides multiple examples through the project.
- [Instructor] So you have heard me talking…about resolvers in C2 so far.…Basically, resolvers are the functions…that respond to queries and mutations.…They are the function that gives us the result of the query.…And because the standard approach is to leave the schema…only for type definition, we create those functions…separate from the schema.…So you can get either have them…in a separate file and then import them…into your main server file,…or have them into your main entry server file,…in this case our index.js.…So we used the second method thus far,…so let's extract the resolvers into their own file…and go through the ones we have so far.…
Okay, so first go into the index.js,…and basically copy from line 43 up…up to the class, so line 11.…So 11 through 43, cut that,…and then let's create a new file.…So use whatever function you use to create a new file.…So in this case I'm using this little icon here.…New file, and I'll call this file resolvers.js,…and then in this new file I will paste…the code that I extracted like so.…
- 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
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.