feat: add lastUsedMachineName field to GraphQL customer type
This commit is contained in:
parent
eae24505f7
commit
05ac89f6fa
2 changed files with 10 additions and 2 deletions
|
|
@ -3,15 +3,22 @@ const anonymous = require('../../../constants').anonymousCustomer
|
|||
const customers = require('../../../customers')
|
||||
const filters = require('../../filters')
|
||||
const customerNotes = require('../../../customer-notes')
|
||||
const machineLoader = require('../../../machine-loader')
|
||||
|
||||
const getCustomerById = customerId =>
|
||||
customers.getCustomerById(customerId)
|
||||
.then(customer =>
|
||||
machineLoader.getMachineName(customer.lastUsedMachine)
|
||||
.then(lastUsedMachineName => Object.assign(customer, { lastUsedMachineName }))
|
||||
)
|
||||
|
||||
const resolvers = {
|
||||
|
||||
Customer: {
|
||||
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||
},
|
||||
Query: {
|
||||
customers: (...[, { phone, email, name, address, id }]) => customers.getCustomersList(phone, name, address, id, email),
|
||||
customer: (...[, { customerId }]) => customers.getCustomerById(customerId),
|
||||
customer: (...[, { customerId }]) => getCustomerById(customerId),
|
||||
customerFilters: () => filters.customer()
|
||||
},
|
||||
Mutation: {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ const typeDef = gql`
|
|||
lastTxFiatCode: String
|
||||
lastTxClass: String
|
||||
lastUsedMachine: String
|
||||
lastUsedMachineName: String
|
||||
transactions: [Transaction]
|
||||
subscriberInfo: JSONObject
|
||||
phoneOverride: String
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue