2016-10-10 18:37:26 +03:00
|
|
|
const AccountType = require('../types/login');
|
|
|
|
const api = require('../../api');
|
|
|
|
|
2017-04-27 21:26:15 +03:00
|
|
|
const { GraphQLBoolean, GraphQLString } = require('graphql');
|
2016-10-10 18:37:26 +03:00
|
|
|
|
|
|
|
module.exports.updateAccount = {
|
|
|
|
type: AccountType,
|
|
|
|
description: 'Update your account details',
|
|
|
|
args: {
|
|
|
|
email: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
company_name: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
first_name: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
last_name: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
address: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
postal_code: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
city: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
country: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
phone: {
|
|
|
|
type: GraphQLString
|
|
|
|
},
|
|
|
|
cns_enabled: {
|
|
|
|
type: GraphQLBoolean
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: (root, args) => {
|
2017-04-27 21:26:15 +03:00
|
|
|
return api.account.get().then(account => {
|
|
|
|
return api.account.update(
|
|
|
|
Object.assign(account, args, {
|
|
|
|
firstName: args.first_name || account.firstName,
|
|
|
|
lastName: args.first_name || account.lastName,
|
|
|
|
companyName: args.company_name || account.companyName,
|
|
|
|
postalCode: args.postal_code || account.postalCode
|
|
|
|
})
|
|
|
|
);
|
2016-10-10 18:37:26 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|