Recall & Review
beginner
What is a default resolver in GraphQL?
A default resolver is the built-in function GraphQL uses to fetch the value of a field when no custom resolver is provided. It simply returns the property of the source object that matches the field name.
Click to reveal answer
beginner
How does GraphQL's default resolver find the value for a field?
It looks for a property on the parent object with the same name as the field and returns its value directly.
Click to reveal answer
intermediate
When would you need to write a custom resolver instead of relying on the default resolver?
When the data needs transformation, fetching from another source, or combining multiple fields, you write a custom resolver. The default resolver only returns existing properties as-is.
Click to reveal answer
beginner
True or False: The default resolver can handle nested objects automatically.
True. If the field's value is an object, the default resolver returns it, and GraphQL continues resolving fields on that nested object.
Click to reveal answer
beginner
What happens if the default resolver does not find a matching property on the source object?
It returns null or undefined, which means the field will have no value in the query result unless a custom resolver handles it.
Click to reveal answer
What does the default resolver in GraphQL do when resolving a field?
✗ Incorrect
The default resolver returns the property on the source object that matches the field name.
When is a custom resolver necessary instead of using the default resolver?
✗ Incorrect
Custom resolvers are needed when data requires fetching from other sources or transformation.
If a field's value is an object, how does the default resolver handle it?
✗ Incorrect
The default resolver returns the object, allowing GraphQL to resolve nested fields.
What will the default resolver return if the source object does not have the requested field?
✗ Incorrect
If the property is missing, the default resolver returns null or undefined.
Which of the following is NOT true about default resolvers?
✗ Incorrect
Default resolvers do not fetch data from databases automatically; they just return existing properties.
Explain how GraphQL's default resolver works when resolving a field in a query.
Think about how GraphQL finds the value without custom code.
You got /4 concepts.
Describe a situation where you would need to write a custom resolver instead of relying on the default resolver.
When the data is not directly available as a simple property.
You got /4 concepts.