Skip to content

Instantly share code, notes, and snippets.

@AlecAivazis
Last active May 31, 2019 01:52
Show Gist options
  • Save AlecAivazis/64a022a80f2ca5fb28951f2f27febaba to your computer and use it in GitHub Desktop.
Save AlecAivazis/64a022a80f2ca5fb28951f2f27febaba to your computer and use it in GitHub Desktop.
User: {
...otherResolvers,
photoGallery: (user, _, { headers }) => {
// if the USER_ID header is not the same ID as the user
if (user.id !== headers.USER_ID) {
throw new Error("Sorry, you cannot view someone else's photo gallery.")
}
// the current user can see this user's photo gallery
return root.photoGallery.map(id => photos[id])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment