23 lines
885 B
JavaScript
23 lines
885 B
JavaScript
const anonymous = require('../../../constants').anonymousCustomer
|
|
const customers = require('../../../customers')
|
|
const filters = require('../../filters')
|
|
|
|
const resolvers = {
|
|
Customer: {
|
|
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
|
},
|
|
Query: {
|
|
customers: (...[, { phone, name, address, id }]) => customers.getCustomersList(phone, name, address, id),
|
|
customer: (...[, { customerId }]) => customers.getCustomerById(customerId),
|
|
customerFilters: () => filters.customer()
|
|
},
|
|
Mutation: {
|
|
setCustomer: (root, { customerId, customerInput }, context, info) => {
|
|
const token = !!context.req.cookies.lamassu_sid && context.req.session.user.id
|
|
if (customerId === anonymous.uuid) return customers.getCustomerById(customerId)
|
|
return customers.updateCustomer(customerId, customerInput, token)
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = resolvers
|