In this video Emmanuel Henri demonstrates how enums work and what they do to restrict the data a field can take, in this case the gender in the Friend type.
- [Instructor] Enumeration type, or commonly called enums,…is a special scale type that allows you to define…a specific set of data the field takes,…and restrict the input to what you list in the enum type.…Let me demonstrate so we can make better sense of this type.…So if you don't have schema.js open, click on schema.js,…and then just below the type on line 12,…hit return and then we'll set a new enum type.…So it's basically the way it's spelled, enum,…and then we'll set an enum type for gender.…
So we want to restrict the choices that gender…is allowing to enter.…So what we are going to do is, MALE,…and by the way, all the fields inside of an enum…should be uppercase.…So MALE, FEMALE, and then OTHER.…And then make sure that you have that change…in here, in the gender,…so now it's taking a gender type,…and also in the input, because if you don't have it…in the input, you'll be able to enter a string in the input…and then when it returns it, it's not going…to be able to return the right values.…
So let's make sure that we have it here as well, 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
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.