refactor: schema modularization
This commit is contained in:
parent
d9e3a9e61f
commit
82b5db6908
35 changed files with 2423 additions and 685 deletions
21
lib/new-admin/graphql/resolvers/customer.resolver.js
Normal file
21
lib/new-admin/graphql/resolvers/customer.resolver.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const anonymous = require('../../../constants').anonymousCustomer
|
||||
const customers = require('../../../customers')
|
||||
|
||||
const resolvers = {
|
||||
Customer: {
|
||||
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||
},
|
||||
Query: {
|
||||
customers: () => customers.getCustomersList(),
|
||||
customer: (...[, { customerId }]) => customers.getCustomerById(customerId)
|
||||
},
|
||||
Mutation: {
|
||||
setCustomer: (root, { customerId, customerInput }, context, info) => {
|
||||
const token = context.req.cookies && context.req.cookies.token
|
||||
if (customerId === anonymous.uuid) return customers.getCustomerById(customerId)
|
||||
return customers.updateCustomer(customerId, customerInput, token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = resolvers
|
||||
Loading…
Add table
Add a link
Reference in a new issue