fix: use gql upload lib and remove logs

This commit is contained in:
José Oliveira 2021-11-09 13:55:12 +00:00
parent 3e4f4a4962
commit 68c635ce38
10 changed files with 112 additions and 70 deletions

View file

@ -27,9 +27,10 @@ const resolvers = {
return customers.edit(customerId, editedData, token)
},
replacePhoto: async (root, { customerId, photoType, newPhoto }, context) => {
const token = !!context.req.cookies.lid && context.req.session.user.id
const photo = await newPhoto
return customers.replacePhoto(customerId, photoType, photo)
.then(() => customers.getCustomerById(customerId))
return customers.updateEditedPhoto(customerId, photo, photoType)
.then(newPatch => customers.edit(customerId, newPatch, token))
},
deleteEditedData: (root, { customerId, customerEdit }) => {
return customers.deleteEditedData(customerId, customerEdit)

View file

@ -1,12 +1,13 @@
const { GraphQLDateTime } = require('graphql-iso-date')
const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
const { GraphQLUpload } = require('graphql-upload')
GraphQLDateTime.name = 'Date'
const resolvers = {
JSON: GraphQLJSON,
JSONObject: GraphQLJSONObject,
Date: GraphQLDateTime
Date: GraphQLDateTime,
UploadGQL: GraphQLUpload
}
module.exports = resolvers