Skip to content

Instantly share code, notes, and snippets.

@philsch
Last active January 13, 2019 11:06
Show Gist options
  • Save philsch/b7d451b740b73437788a0d0a15ddf677 to your computer and use it in GitHub Desktop.
Save philsch/b7d451b740b73437788a0d0a15ddf677 to your computer and use it in GitHub Desktop.
Blogpost: Monitor your GraphQL Apollo Server in Google Cloud
// ...
const simulateDbDown = async () => {
if (Math.random() > 0.7) {
throw new DatabaseError('[TEST] Oh no the database is down!');
}
};
const resolvers = {
Query: {
books: async (parent, args) => {
await simulateDbDown();
if (!args.author) {
return exampleBooks;
}
return exampleBooks.filter((el) => el.author === args.author);
}
}
};
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment