In GraphQL SDL, the ! (exclamation mark) after a field type means:
Non-null (!) in SDL guarantees that the field will always have a value. name: String! means name is always a String, never null. This affects client null-safety handling and is a key schema design decision.
2 / 12
GraphQL has three operation types. Which of the following is NOT a valid GraphQL operation?
GraphQL defines three operation types: Query (read), Mutation (write), Subscription (real-time). 'Transaction' is not a GraphQL concept — mutations are used for writes, and atomicity must be handled at the application layer.
3 / 12
What is the difference between an Interface and a Union in GraphQL?
Interface: all implementing types share the interface's fields (e.g., Node with id). Union: a field can return one of several unrelated types (e.g., SearchResult = User | Post | Product) — no shared fields required.
4 / 12
Which of these is a custom scalar in GraphQL?
GraphQL's built-in scalars are String, Int, Float, Boolean, ID. 'Date' is not built-in — it is a common custom scalar added by schemas to represent date/time values, typically serialised as ISO 8601 strings or Unix timestamps.
5 / 12
Fill in the blank: "Our search endpoint returns a ___ type because results can be either a User, a Post, or a Product."
A Union is the right choice when a field can return one of several unrelated types. The client uses inline fragments to handle each type: ... on User { name }, ... on Post { title }.
6 / 12
Reviewer: 'I'm seeing a lot of `__type` fields being used here. Is this intentional? We're defining multiple types for the `Product` schema, and I wasn't sure if we should be using a Union to handle that.' What does Reviewer mean when he asks about using `__type` fields in this context?
Reviewer is referring to GraphQL Union Types. The `__type` field within a Union indicates that a particular field can accept values of different types specified in the Union definition. Using Unions allows you to represent diverse data structures for a single field, which is a core concept in SDL. Options A and D are incorrect; required fields use validation rules, and deprecated keywords aren't relevant here.
7 / 12
Reviewer: 'I'm seeing a lot of `__type` fields being used here. Is this intentional? We're defining multiple types for the `Product` schema, and I wasn't sure if we should be using a Union to handle that.' What does Reviewer mean when he asks about using `__type` fields in this context?
Reviewer is referring to GraphQL Union Types. The `__type` field within a Union indicates that a particular field can accept values of different types specified in the Union definition. Using Unions allows you to represent diverse data structures for a single field, which is a core concept in SDL. Options A and D are incorrect; required fields use validation rules, and deprecated keywords aren't relevant here.
8 / 12
Reviewer: 'I'm noticing a lot of `__kind` fields being used. Can you explain the rationale here? It seems a bit verbose for our simple User type.' What does the reviewer likely mean when they mention `__kind`?
The `__kind` field in SDL is used to provide additional information about the *type* of a field. It's essentially metadata that helps GraphQL resolvers understand how to resolve nested fields—it's not directly related to the data type itself (which is defined by the `__type` field). Using it excessively can make the schema less readable.
9 / 12
DevA: 'Hey team, I'm struggling to understand how to properly define a Union type for our Product schema. We have different product types (eBook, Physical Book, Digital Download), and I'm not sure if I should be using a Union or multiple interfaces.' What is DevA primarily asking about?
DevA is grappling with the fundamental difference between Unions and Interfaces in SDL. While both allow you to define multiple possible types, a Union represents a *choice* among different types, whereas an Interface defines a shared contract that concrete types must implement. DevA's confusion highlights this core distinction.
The `__type: "non-nullable scalar"` field in this GraphQL response is crucial. It explicitly defines the data type of the `product` field as a scalar—in this case, likely a string—and confirms that it's not allowed to be null. This information is vital for resolvers to correctly process and interpret the data.
11 / 12
'Implemented a new endpoint to fetch product details. Used a Union type to handle different product categories (eBook, Physical Book). The schema now supports multiple product types efficiently.'
What is the primary benefit of using a Union type in this scenario, according to the PR description?
The PR description clearly states that the Union type is used to 'handle multiple product types efficiently.' This directly addresses the core purpose of Unions – allowing a field to accept values from several distinct types without requiring separate schema definitions for each. Using a single union avoids code duplication and simplifies maintenance.
12 / 12
Developer: 'I'm working on the product search endpoint. I've been using `__type` fields extensively to define different types for User, Post, and Product results.' What is a potential concern this developer should consider regarding their approach?
While `__type` fields are necessary for GraphQL resolvers to understand the structure of nested fields, excessive use can lead to a verbose and complex schema. A cleaner approach would be to carefully consider whether Unions or Interfaces (or a combination) better represent the relationships between your data types, prioritizing readability and maintainability over potentially unnecessary details provided by `__type`.
This module has 12 multiple-choice exercises, each with instant feedback and a full explanation of the correct answer.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall.
Do I need to create an account to do these exercises?
No account is required. Just click an option to answer — your score for this session is tracked automatically in the progress bar above.
What happens if I choose the wrong answer?
You'll immediately see which answer was correct, plus a full explanation covering the vocabulary and reasoning behind it — mistakes are where most of the learning happens.
Can I retry the exercises if I want a higher score?
Yes — use the "Try again" button on the results screen to reset and go through all the questions again.
Is my progress saved if I close the page?
No. Progress is tracked only for your current visit; reloading or leaving the page resets the counter. This keeps the exercise simple and account-free.
Where can I find more GraphQL & API Gateway Language exercises?
Browse the full GraphQL & API Gateway Language hub for related drills, or check the "Next up" link below to continue with a connected topic.
How is this different from reading an article on the same topic?
Articles explain vocabulary and concepts in prose; this exercise tests and reinforces that vocabulary through active recall with immediate feedback — the two work best together.
Who writes these exercises?
Every exercise is written by the CoderSlingo team, drawing on real workplace English used in IT roles, then reviewed for accuracy and clarity.