Skip to content

Instantly share code, notes, and snippets.

@bartcis
Created July 17, 2019 10:40
Show Gist options
  • Select an option

  • Save bartcis/1106a82bb32cff0037ad192586d7c1c9 to your computer and use it in GitHub Desktop.

Select an option

Save bartcis/1106a82bb32cff0037ad192586d7c1c9 to your computer and use it in GitHub Desktop.
Basic configuration for Apollo Server
const { ApolloServer } = require('apollo-server');
// Import of the file where we define/fetch data
const api = require('./server/api');
// Import of the file where we build data structures/schemas
const typeDefs = require('./server/schema');
// Bind queries from schemas definition to data from API's
const resolvers = {
Query: {
books: () => api.books,
countries: () => api.countries
},
};
// Build new server
const server = new ApolloServer({ typeDefs, resolvers });
// Start new server
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment