Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.

Latest commit

 

History

History
40 lines (25 loc) · 1.45 KB

03-query-an-enumeration-type-with-graphql.md

File metadata and controls

40 lines (25 loc) · 1.45 KB

Video Link

Summary

We'll query an enum field, category, in this lesson to find out the different pet categories. This lesson also takes a look at the GraphQL schema for the API.

Notes

When we're using GraphQL Playground, we can hit CTRL+SPACE. This will surface all of the different fields that are available on this query.

Add category to our query. When clicking play, you should see category being returned.

query {
  allPets {
    name
    weight
    category
  }
  totalPets
}

GraphQL is a query language for your API, but it's also a type system for your API.

The GraphQL spec describes a schema definition language, which we'll use to define all of the different queries and all of the different types that are available on this API.

If you click the schema tab, you can take a look at this schema.

alt text

petCategory is an enumeration type that represents a restricted list of options for this field.

Personal Take

🔥Tip: You can hover over one of these field names and press command. This will allow you to click on that field, and it'll take you directly to that field definition in the schema.

Resources