Recall & Review
beginner
What is a SQL database resolver in GraphQL?
A SQL database resolver is a function in GraphQL that fetches data from a SQL database when a query or mutation is executed. It connects GraphQL queries to the database.
Click to reveal answer
beginner
How does a resolver function typically interact with a SQL database?
It runs SQL queries or commands to get or modify data, then returns the results to GraphQL to send back to the client.
Click to reveal answer
intermediate
Why do we use resolvers in GraphQL instead of direct SQL queries in the client?
Resolvers keep the database secure and hidden. They let the server control what data is sent and how, avoiding direct database access from clients.Click to reveal answer
intermediate
What is the role of arguments in SQL database resolvers?
Arguments let clients specify details like which records to fetch or update. The resolver uses these to build the right SQL query.Click to reveal answer
beginner
Give an example of a simple SQL database resolver for fetching a user by ID.
Example resolver: async function getUser(parent, args) { return await db.query('SELECT * FROM users WHERE id = ?', [args.id]); }Click to reveal answer
What does a SQL database resolver do in GraphQL?
✗ Incorrect
Resolvers connect GraphQL queries to the database by fetching or modifying data.
Why should clients not run SQL queries directly in GraphQL?
✗ Incorrect
Resolvers protect the database by controlling access and hiding direct queries from clients.
What do resolver arguments help with?
✗ Incorrect
Arguments let clients tell the resolver what specific data they want.
Which of these is a typical step inside a SQL database resolver?
✗ Incorrect
Resolvers run SQL queries to get or change data in the database.
What is returned by a SQL database resolver?
✗ Incorrect
Resolvers return the data fetched from the database to GraphQL.
Explain in your own words what a SQL database resolver does in a GraphQL server.
Think about how GraphQL gets data from a SQL database.
You got /4 concepts.
Describe why using resolvers improves security compared to letting clients run SQL queries directly.
Consider what could happen if clients had direct database access.
You got /4 concepts.