Created
July 17, 2019 10:40
-
-
Save bartcis/1106a82bb32cff0037ad192586d7c1c9 to your computer and use it in GitHub Desktop.
Basic configuration for Apollo Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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