Skip to content

Instantly share code, notes, and snippets.

@stubailo
Last active August 6, 2019 22:57
Show Gist options
  • Save stubailo/f6d349a961edb192ee457061b1a96a0e to your computer and use it in GitHub Desktop.
Save stubailo/f6d349a961edb192ee457061b1a96a0e to your computer and use it in GitHub Desktop.
Apollo Server Lambda hello world
// src/lambda/graphql.js
const { ApolloServer, gql } = require("apollo-server-lambda");
const typeDefs = gql`
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: (root, args, context) => {
return "Hello, world!";
}
}
};
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: true
});
exports.handler = server.createHandler();
@kilbot
Copy link

kilbot commented Mar 8, 2019

Hi @stubailo, thanks for the tutorial!

I'm just working my through and noticed that the requirements to get the playground in src/lambda/graphql.js have changed.

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: true,
  playground: true
});

@capaj
Copy link

capaj commented Aug 6, 2019

@kilbot thanks for this! Just was about to suggest the same.

@stubailo
Copy link
Author

stubailo commented Aug 6, 2019

Updated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment