Given a GraphQL schema where Author has many Books, what is the output of this query?
query {
authors {
name
books {
title
}
}
}Assume the data has one author named "Alice" with two books titled "GraphQL Basics" and "Advanced GraphQL".
query {
authors {
name
books {
title
}
}
}Think about how one-to-many relationships return nested lists in GraphQL.
The query requests each author's name and their list of books with titles. Since Alice has two books, both appear nested under her.
Which of the following GraphQL field definitions best represents a many-to-many relationship between Student and Course?
Many-to-many means each side can have multiple related items.
Option A uses lists on both sides, indicating multiple courses per student and multiple students per course, which is many-to-many.
Which option shows the correct GraphQL syntax for a one-to-one relationship where a User has one Profile?
One-to-one means exactly one related item, not a list.
Option A declares the profile field as non-nullable single Profile, matching one-to-one.
You have a GraphQL query fetching Posts with their Comments and each comment's Author. Which approach reduces over-fetching and improves performance?
Fragments help reuse and limit fields fetched.
Using fragments to select only necessary fields avoids fetching unnecessary data and improves query efficiency.
Given a GraphQL schema where Employee has a manager who is also an Employee, this query causes an error:
query {
employees {
name
manager {
name
manager {
name
}
}
}
}What is the most likely cause of the error?
Think about how recursive relationships can cause problems in queries.
Querying nested managers repeatedly without limiting depth can cause infinite recursion or stack overflow errors.