In this video Emmanuel Henri demonstrates how to use fragments to query multiple items and maximize the size of your queries in GraphQL.
- [Instructor] Like Aliases, fragments are a neat feature…that comes built in with GraphQL…and is very useful when we start requesting…the same data across several items.…Let me demonstrate.…So in this case we actually ask…for different data for the two requests here.…So, what we'll do is change those two…and then use a fragment to ask for the same data…but not have to re-type the same thing across.…So, let's say for example, we had…first name, last name, here as well.…And then we'd have like 20 other queries…in the same request.…
Then that would become very repetitive.…And that's what we want to avoid with a fragment.…So what we do is basically do a second line below…and call this one fragment.…And we call, so for example, we call this one…friend fragment on friend.…And this is how we type a fragment.…And then what we do is specify what we want…to return on this fragment.…
So, first name, last name.…And then what we have to do is change…on each of our queries with three dots…and then say friend fragment…and then do the same on the second line.…
- 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.