Understanding Typedefs and Resolvers
In this section we will further explore GraphQL schemas, but we will also implement resolvers, which are the functions that do the actual work. This section will also introduce us to Apollo GraphQL and how to create a GraphQL server instance.
What are resolvers? Resolvers are the functions that get or edit the data from our datastore. This data is then matched with the GraphQL type definition.
In order to see what the role of resolvers is in more depth, we need to continue building out our previous project. Let's look at the steps:
- Install the dependency UUID. This tool will allow us to create a unique ID for our
ID
types:npm i uuid @types/uuid
- Create a new file called
server.ts
, which will start our server, with this code:import express from "express"; import { ApolloServer, makeExecutableSchema } from "apollo-server-express"; import typeDefs from "./typeDefs"; import resolvers from "./resolvers...