Skip to content

Instantly share code, notes, and snippets.

@sericaia
Last active January 29, 2019 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sericaia/9228e32b1f30d40888bb5e02bdbd4864 to your computer and use it in GitHub Desktop.
Save sericaia/9228e32b1f30d40888bb5e02bdbd4864 to your computer and use it in GitHub Desktop.
// resolver code
employee: async (root, { where: { email, slackId } }, { dataSources }) => {
if (!email && !slackId) {
throw new Error('Email or SlackId are required.');
}
if (email) {
return getEmployeeFromEmail(email, dataSources);
}
if (slackId) {
return getEmployeeFromSlackId(slackId, dataSources);
}
return null;
},
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment