-
-
Save kimiiz55/bb6a64e454979bbe7d2815d3d7a0b908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { getUserId } = require("../../utils"); | |
const { processUpload } = require("../../modules/fileApi"); | |
const 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); | |
return ctx.db.mutation.createSupplierProduct( | |
{ | |
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 } | |
}, | |
images: { | |
connect: { id: [...imageId] } | |
} | |
} | |
}, | |
info | |
); | |
} | |
}; | |
module.exports = { supplierProduct }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
connect
accepts an array of objects. Doing something like below should help: