Skip to content

Commit

Permalink
switch to async function for server start instead of callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mabuyo committed Aug 16, 2021
1 parent 9401d87 commit d5a80af
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
const { ApolloServer } = require('apollo-server');
const typeDefs = require('./schema');
const resolvers = require('./resolvers');

const TrackAPI = require('./datasources/track-api');

const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => {
return {
trackAPI: new TrackAPI(),
};
},
});
async function startApolloServer(typeDefs, resolvers) {
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => {
return {
trackAPI: new TrackAPI(),
};
},
});

server.listen().then(() => {
const { url, port } = await server.listen();
console.log(`
🚀 Server is running!
🔉 Listening on port 4000
📭 Query at https://studio.apollographql.com/dev
`);
});
🚀 Server is running
🔉 Listening on port ${port}
📭 Query at ${url}
`);
}

startApolloServer(typeDefs, resolvers);

0 comments on commit d5a80af

Please sign in to comment.