Week 8 Waivy Pickups

Ted Ginn has been trending with the red hot New Orleans Saints the last 2 weeks. He really broke out against the Green Bay Packers Sunday with a 7 reception 141-yard day. A stat that I thought was…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to Query Enums with GraphQL using Introspection

When you are working on a project that allows users to pick an option, such as a school name, it is best to query for these values from your database instead of storing them on a list. This is because if new options are added you won’t have to worry about updating a list on the frontend. Moreover, if you needed to use these values in another file you could simply call the enum query.

For this example, I will be using an enum that stores the names of 7 universities.

Here’s how to query this enum:

Once you run this query your result should look like this:

This returns the name of the enum with all of its values. To use these values, store them in a variable when querying the enums. The statement should look like this:

The end result should look like this

Using introspection is easy and it’s a great way to reduce the number of variables that store the same information in your database. The best thing about using introspection is that no changes need to be done to the frontend to update the list being displayed.

Add a comment

Related posts:

All Things Data Podcast with Dr. Tim Chou

Dr. Chou started his career in Silicon Valley at one of the first Kleiner-Perkins startups, Tandem Computers. Since then he’s been lucky enough to be a part of some successful and not so successful…

Development

Rewards are continuously calculated on the Orbs network; Click here for the details. They are sent directly to the addresses of the Orbs participants and include Participation (delegation), Guardian…

The third part of the stars

In the book of Revelation, Jesus reveals to us the mystery which was hidden in the eternity past. We read about the dragon, also called the old serpent. This dragon is a representation of Satan, it…