concept resolver in category graphql

This is an excerpt from Manning's book GraphQL in Action.
To understand how resolvers work, let’s take the query in listing 1.5 (simplified) and assume a client sent it to a GraphQL service:
Luckily, this has been done already! We don’t have to re-implement any of the steps above except for dealing with schema and resolvers. The rest is where a GraphQL "implementation" comes into the picture!

This is an excerpt from Manning's book Fullstack GraphQL Applications With GRANDstack.
But where does the data come from? The data fetching logic for GraphQL APIs is defined in functions called resolvers, which contain the logic for resolving the data for an arbitrary GraphQL request from the data layer. GraphQL is data layer agnostic so the resolvers could query one or more databases or even fetch data from another API, even a REST API. We will cover resolvers in depth in the next chapter.
2.2.2 Resolving data with resolvers
Following our GraphQL First Development approach the next step we need to complete is implementing the code to actually fetch this data from the data layer. We do this by writing functions called resolvers that contain logic for how to resolve data from the data layer. Resolvers are stand-alone functions whose purpose is to fetch data for a single field of a GraphQL type and can be thought of as the primary unit of execution in a GraphQL service. Resolvers are called in a nested fashion, starting with the root-level resolver (a field on the Query, Mutation, or Subscription types) in a depth-first execution until all requested fields have been resolved. Data resolved in a previous resolver is passed on to nested resolvers via the
objparameter.You can think of resolvers as functions that go alongside the GraphQL type definitions defined in SDL, and effectively make the GraphQL schema "executable". A GraphQL schema must have resolver functions for all fields so a collection of resolver functions corresponds to the type definitions and is known as a resolver map.
Let’s implement resolvers for the type definitions we’ve created above. The first thing we need is some data to return, so lets create some hard-coded data that will represent our data layer. We’ll simply create some object literals and store these in an object called
db, which we can think of as a mock for a database that we would query in our resolver functions. We will inject thisdbobject with our fake data into thecontextobject, ensuring it is available in each resolver.Listing 2.9. Sample data for businesses, reviews, and users representing our data layer
const businesses = [ { businessId: "b1", name: "Missoula Public Library", address: "301 E Main St, Missoula, MT 59802", reviewIds: ["r1", "r2"] }, { businessId: "b2", name: "San Mateo Public Library", address: "55 W 3rd Ave, San Mateo, CA 94402", reviewIds: ["r3"] } ]; const reviews = [ { reviewId: "r1", stars: 3, text: "Friendly staff. Interlibrary loan is super fast", businessId: "b1", userId: "u1" }, { reviewId: "r2", stars: 4, text: "Easy downtown access, lots of free parking", businessId: "b1", userId: "u2" }, { reviewId: "r3", stars: 5, text: "Lots of glass and sunlight for reading. Comfy chairs in large print section.", businessId: "b1", userId: "u1" } ]; const users = [ { userId: "u1", name: "Will", reviewIds: ["r1", "r2"] }, { userId: "u2", name: "Bob", reviewIds: ["r3"] } ]; const db = { businesses, reviews, users };We’ll assume these objects are passed to the resolvers in the context object, such as we would pass a database connection object.