Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Created May 2, 2018 21:11
Show Gist options
  • Save peggyrayzis/cf7beaf050f9b3cfa6a20bbf4195bca5 to your computer and use it in GitHub Desktop.
Save peggyrayzis/cf7beaf050f9b3cfa6a20bbf4195bca5 to your computer and use it in GitHub Desktop.
Apollo Server 2.0
const { ApolloServer, gql } = require('apollo-server');
// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type Query {
hello: String
}
`;
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => "world"
}
};
const server = new ApolloServer({ typeDefs, resolvers });
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