Module 3 Summary
This lesson is a summary of the final state of the work done in Module 3.0.
In Module 3, we've set up a GraphQL API with Apollo Server (in particular with the
In the main
src/index.ts file, we set up a new Apollo Server instance with the
ApolloServer constructor. In the
ApolloServer constructor, we pass in a
typeDefs string and a
resolvers map that we've created in the
src/graphql/ folder of our app.
We applied middleware on the Apollo Server instance and passed in the Express
app instance as well as specified the path of our API endpoint to be
typeDefs (i.e. type definitions) is a string that represents the GraphQL schema. In the
src/graphql/typeDefs.ts file, we use the
gql tag that
apollo-server-express provides to help parse a template literal into a GraphQL Abstract Tree.
We created a
Listing GraphQL object type that represents the shape of a single listing. We also created the root
Mutation object types. In the root
Query type, we established a
listings field where we return a list of listings. The
deleteListing field in our
Mutation object accepts an
id argument and when complete returns the deleted listing.