Bird
0
0

Given this schema snippet:

medium📝 query result Q4 of 15
GraphQL - Schema Definition Language (SDL)
Given this schema snippet:
type Query { book(id: ID!): Book }

and a query:
{ book(id: "1") { title } }

What will the API return if the book with id "1" exists?
AThe title of the book with id "1"
BAn error because id is not an Int
CA list of all books ignoring the id
DNull because the schema is incomplete
Step-by-Step Solution
Solution:
  1. Step 1: Understand the schema and query

    The schema defines a Query type with a 'book' field taking a non-null ID argument and returning a Book.
  2. Step 2: Analyze the query execution

    The query requests the book with id "1" and asks for its title. If the book exists, the API returns its title.
  3. Final Answer:

    The title of the book with id "1" -> Option A
  4. Quick Check:

    Valid id query returns book title = A [OK]
Quick Trick: Non-null ID means id must be provided and valid [OK]
Common Mistakes:
  • Confusing ID with Int type
  • Expecting list instead of single item
  • Assuming incomplete schema causes null

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes