Created
February 26, 2018 23:26
-
-
Save LawJolla/5bd7df514f5a3de4ef9178f836bcc2ee to your computer and use it in GitHub Desktop.
Query Schema with permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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