Created
February 6, 2020 16:12
-
-
Save lindenmelvin/2c32a584ab2ff7919c2bde02380d917c to your computer and use it in GitHub Desktop.
This file contains 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, gql } = require('apollo-server'); | |
const resolvers = require("./resolvers"); | |
const typeDefs = gql` | |
type Post { | |
title: String! | |
authorId: String! | |
} | |
type Query { | |
posts: [Post!]! | |
} | |
`; | |
const context = () => { | |
return { | |
user: { id: 1 } | |
} | |
} | |
const server = new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context | |
}); | |
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