Skip to content

Instantly share code, notes, and snippets.

@LawJolla
Created February 26, 2018 23:26
Show Gist options
  • Save LawJolla/5bd7df514f5a3de4ef9178f836bcc2ee to your computer and use it in GitHub Desktop.
Save LawJolla/5bd7df514f5a3de4ef9178f836bcc2ee to your computer and use it in GitHub Desktop.
Query Schema with permissions
const Query = {
vehicles: async (parent, args, context, info) => {
const vehicles = await context.db.query.vehicles({
where: { dealership: args.id }
})
const user = getUser(context)
return vehicles.map(vehicle => ({
...vehicle,
costBasis:
user && user.role.includes(`MANAGER`) ? vehicle.costBasis : null,
numberOfOffers: user ? vehicle.numberOfOffers : null
}))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment