sdy

update server.js

1 -import { GraphQLServer } from "graphql-yoga";
2 import dotenv from "dotenv"; 1 import dotenv from "dotenv";
3 dotenv.config(); 2 dotenv.config();
3 +import { GraphQLServer } from "graphql-yoga";
4 +import morgan from "morgan";
5 +import schema from "./schema";
4 6
5 -const PORT = process.env.PORT || 4000; 7 +const PORT = process.env.PORT;
6 -
7 -const typeDefs = `
8 - type Query {
9 - hello(name: String): String
10 - }
11 -`;
12 8
13 -const resolvers = { 9 +const server = new GraphQLServer({ schema });
14 - Query: {
15 - hello: () => "hello",
16 - },
17 -};
18 10
19 -const server = new GraphQLServer({ typeDefs, resolvers }); 11 +server.express.use(morgan("dev"));
20 12
21 server.start(() => console.log(`server is running : http://localhost:${PORT}`)); 13 server.start(() => console.log(`server is running : http://localhost:${PORT}`));
......