Skip to content

Instantly share code, notes, and snippets.

@lorensr
Created April 2, 2020 09:31
Show Gist options
  • Save lorensr/e184c1bc8fd859086832e14d5a09ce0b to your computer and use it in GitHub Desktop.
Save lorensr/e184c1bc8fd859086832e14d5a09ce0b to your computer and use it in GitHub Desktop.
const resolvers = {
Query: {
getFoo: (_, { id }, context) =>
context.dataSources.myFoos.get(id, { ttlInSeconds: 60 })
},
Mutation: {
updateFoo: async (_, { id, fields }, context) => {
if (context.isAdmin) {
context.dataSources.myFoos.updateFields(id, fields)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment