Recall & Review
beginner
What is a mocking resolver in GraphQL?
A mocking resolver is a fake function that returns sample data instead of real data, used to test or develop GraphQL APIs without a real backend.
Click to reveal answer
beginner
Why use mocking resolvers during GraphQL API development?
They let you build and test the API schema quickly without needing a real database or backend, helping frontend and backend teams work in parallel.Click to reveal answer
intermediate
How do you define a simple mocking resolver for a 'User' type with a 'name' field?
You write a resolver function that returns a fixed or random name string when the 'name' field is requested, for example: <br>
{ User: { name: () => 'Alice' } }Click to reveal answer
intermediate
What is the benefit of using libraries like Apollo Server's mocking feature?
They automatically generate fake data for your schema types, saving time and reducing manual work when mocking resolvers.
Click to reveal answer
advanced
Can mocking resolvers simulate errors or delays? Why is this useful?
Yes, mocking resolvers can simulate errors or delays to test how your app handles failures or slow responses, improving robustness.
Click to reveal answer
What does a mocking resolver return in GraphQL?
✗ Incorrect
Mocking resolvers return sample or fake data to simulate real responses.
Which of these is a reason to use mocking resolvers?
✗ Incorrect
Mocking resolvers help frontend developers work without waiting for backend completion.
How can you simulate a delay in a mocking resolver?
✗ Incorrect
Using a delay function like setTimeout simulates slow responses.
Which GraphQL server library has built-in mocking support?
✗ Incorrect
Apollo Server includes features to easily mock GraphQL schemas.
What is a key limitation of mocking resolvers?
✗ Incorrect
Mocking resolvers do not fetch real data, so they can't test real backend logic.
Explain what mocking resolvers are and why they are useful in GraphQL development.
Think about how you can test an API without a real database.
You got /3 concepts.
Describe how you would create a mocking resolver for a GraphQL type with multiple fields.
Consider how each field needs its own fake data function.
You got /3 concepts.