This video is available to students only
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 apollo-express-server
package).
src/index.ts
#
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 /api
.
1
import express from 'express';
2
import { ApolloServer } from 'apollo-server-express';
3
import { typeDefs, resolvers } from './graphql';
4
5
const app = express();
6
const port = 9000;
7
const server = new ApolloServer({ typeDefs, resolvers });
8
9
server.applyMiddleware({ app, path: '/api' });
10
app.listen(port);
11
12
console.log(`[app] : http://localhost:${port}`);
GraphQL Schema#
This page is a preview of TinyHouse: A Fullstack React Masterclass with TypeScript and GraphQL