0
0
GraphQLquery~15 mins

List types in GraphQL - Mini Project: Build & Apply

Choose your learning style9 modes available
GraphQL List Types Practice
📖 Scenario: You are building a simple GraphQL schema for a bookstore. You want to store a list of book titles available in the store.
🎯 Goal: Create a GraphQL schema that defines a Bookstore type with a field books that is a list of strings representing book titles.
📋 What You'll Learn
Define a GraphQL type called Bookstore
Add a field called books to Bookstore
The books field must be a list of strings
Use proper GraphQL list syntax for the books field
💡 Why This Matters
🌍 Real World
GraphQL schemas often need to represent collections of items, like lists of books, users, or products.
💼 Career
Understanding list types and nullability in GraphQL is essential for backend developers working with APIs.
Progress0 / 4 steps
1
Define the Bookstore type
Create a GraphQL type called Bookstore with no fields yet.
GraphQL
Need a hint?

Start by writing type Bookstore { } to define the type.

2
Add the books field
Inside the Bookstore type, add a field called books with type [String] to represent a list of book titles.
GraphQL
Need a hint?

Use square brackets [] around String to make it a list type.

3
Make the books list non-nullable
Modify the books field so that the list itself cannot be null by adding an exclamation mark ! after the list type.
GraphQL
Need a hint?

Add ! after the list type to make the list non-nullable.

4
Make the book titles non-nullable
Modify the books field so that each book title inside the list is also non-nullable by adding an exclamation mark ! after String inside the list.
GraphQL
Need a hint?

Add ! after String inside the brackets to make each item non-nullable.