Kimiiz
03/13/2018, 7:04 AMKimiiz
03/13/2018, 7:25 AMRaeesaa
03/13/2018, 8:13 AMKimiiz
03/13/2018, 8:19 AMRaeesaa
03/13/2018, 8:22 AMconst supplierProduct = {
async createSupplierProduct(parent, args, ctx, info) {
const images = await Promise.all(
args.files.map(file => processUpload(file, ctx))
);
const imageId = await images.map(image => image.id);
let data = {
name: args.name,
description: args.description,
detail: args.detail,
tags: [...args.tags],
inventory: args.inventory,
retailPrice: args.retailPrice,
wholesalePrice: args.wholesalePrice,
category: {
connect: { id: args.categoryId }
}
}
if(imageId && imageId.length) {
data.images = {
connect: imageId.map((id) => {id})
}
}
return ctx.db.mutation.createSupplierProduct({ data }, info);
}
};
Raeesaa
03/13/2018, 8:23 AMKimiiz
03/13/2018, 8:29 AMerror images":{"connect":[null,null,null]}}; Expected non-nullable
Raeesaa
03/13/2018, 8:32 AMimageIds
. Looks like it is not being built correctly. I guess you should be able to debug thisRaeesaa
03/13/2018, 8:32 AMconst imageIds = await images.map(image => {id: image.id});
?Raeesaa
03/13/2018, 8:33 AMKimiiz
03/13/2018, 8:44 AM