Recall & Review
beginner
What does 'Search across types' mean in GraphQL?
It means querying multiple different data types in a single search, so you can find results from various categories or objects at once.
Click to reveal answer
intermediate
How can you search across different types in GraphQL?
By using a union or interface type that groups multiple types together, then querying that union or interface to get results from all included types.
Click to reveal answer
beginner
What is a GraphQL union type?
A union type lets you combine multiple object types into one, so a query can return different types of objects in the same field.
Click to reveal answer
intermediate
Why use fragments when searching across types?
Fragments let you specify which fields to get from each type in a union or interface, so you get the right data for each kind of result.Click to reveal answer
intermediate
Example: How to write a query that searches across 'Book' and 'Author' types?
Use a union type like 'union SearchResult = Book | Author' and query it with fragments for each type to get fields like title for Book and name for Author.
Click to reveal answer
What GraphQL feature allows combining multiple types for a single search?
✗ Incorrect
Union types let you combine multiple object types so a field can return different types.
When querying a union type, how do you specify fields for each type?
✗ Incorrect
Fragments let you define fields for each type inside a union or interface.
Which of these is NOT a valid use of searching across types?
✗ Incorrect
Searching across types involves objects, not just scalar values.
What keyword defines a union type in GraphQL schema?
✗ Incorrect
'union' keyword is used to define a union type.
Can you use interfaces instead of unions for searching across types?
✗ Incorrect
Interfaces can also group types and be used for searching across types.
Explain how to perform a search across multiple types in GraphQL.
Think about how to combine types and get fields from each.
You got /4 concepts.
Describe the difference between union types and interfaces when searching across types.
Consider how each groups types and what fields they require.
You got /3 concepts.