Skip to content

Instantly share code, notes, and snippets.

@stubailo
Last active August 6, 2019 22:57
Show Gist options
  • Select an option

  • Save stubailo/f6d349a961edb192ee457061b1a96a0e to your computer and use it in GitHub Desktop.

Select an option

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

kilbot commented Mar 8, 2019

Copy link
Copy Markdown

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

capaj commented Aug 6, 2019

Copy link
Copy Markdown

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

@stubailo

stubailo commented Aug 6, 2019

Copy link
Copy Markdown
Author

Updated, thanks!

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