-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
25 lines (21 loc) · 782 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { ApolloServer } from "apollo-server";
import { ApolloServerPluginLandingPageGraphQLPlayground } from "apollo-server-core";
import mongoose from "mongoose";
import gql from "graphql-tag";
import { config } from "./config.js";
import { typeDefs } from "./graphql/typeDefs.js";
import { resolvers } from "./graphql/resolvers/index.js";
const port = process.env.PORT || 4000;
const startServer = async () => {
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({ req }),
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()],
});
await mongoose.connect(config.dbUri).then(() => console.log("connected"));
server
.listen({ port })
.then((res) => console.log(`server running at ${res.url}`));
};
startServer();