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 customers = require('../../../customers')
|
||||||
const filters = require('../../filters')
|
const filters = require('../../filters')
|
||||||
const customerNotes = require('../../../customer-notes')
|
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 = {
|
const resolvers = {
|
||||||
|
|
||||||
Customer: {
|
Customer: {
|
||||||
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||||
},
|
},
|
||||||
Query: {
|
Query: {
|
||||||
customers: (...[, { phone, email, name, address, id }]) => customers.getCustomersList(phone, name, address, id, email),
|
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()
|
customerFilters: () => filters.customer()
|
||||||
},
|
},
|
||||||
Mutation: {
|
Mutation: {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ const typeDef = gql`
|
||||||
lastTxFiatCode: String
|
lastTxFiatCode: String
|
||||||
lastTxClass: String
|
lastTxClass: String
|
||||||
lastUsedMachine: String
|
lastUsedMachine: String
|
||||||
|
lastUsedMachineName: String
|
||||||
transactions: [Transaction]
|
transactions: [Transaction]
|
||||||
subscriberInfo: JSONObject
|
subscriberInfo: JSONObject
|
||||||
phoneOverride: String
|
phoneOverride: String
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue