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

View file

@ -12,7 +12,7 @@ const typeDef = gql`
authorizedOverride: String
daysSuspended: Int
isSuspended: Boolean
newPhoto: Upload
newPhoto: UploadGQL
photoType: String
frontCameraPath: String
frontCameraAt: Date
@ -23,7 +23,7 @@ const typeDef = gql`
idCardData: JSONObject
idCardDataOverride: String
idCardDataExpiration: Date
idCardPhoto: Upload
idCardPhoto: UploadGQL
idCardPhotoPath: String
idCardPhotoOverride: String
usSsn: String
@ -70,7 +70,7 @@ const typeDef = gql`
input CustomerEdit {
idCardData: JSONObject
idCardPhoto: Upload
idCardPhoto: UploadGQL
usSsn: String
}
@ -87,7 +87,7 @@ const typeDef = gql`
removeCustomField(customerId: ID!, fieldId: ID!): CustomerCustomField @auth
editCustomer(customerId: ID!, customerEdit: CustomerEdit): Customer @auth
deleteEditedData(customerId: ID!, customerEdit: CustomerEdit): Customer @auth
replacePhoto(customerId: ID!, photoType: String, newPhoto: Upload): Customer @auth
replacePhoto(customerId: ID!, photoType: String, newPhoto: UploadGQL): Customer @auth
}
`

View file

@ -4,6 +4,7 @@ const typeDef = gql`
scalar JSON
scalar JSONObject
scalar Date
scalar UploadGQL
`
module.exports = typeDef