Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
create: data.variants.map(
variant =>
({
optionValues: {
connect: variant.optionsValueIds,
},
} as VariantCreateInput),
),
},
})
},
})
t.field('updateProduct', 'Product', {
args: {
data: arg('UpdateProductInput', { required: true }),
},
resolve: async (parent, { data }, ctx) => {
throw new Error('updateProduct resolve not implemented yet')
},
})
})
productIds: idArg({ required: true, list: true }),
collectionId: idArg({ required: true }),
},
resolve: async (_, args, ctx) => {
const collection = await ctx.prisma.updateCollection({
where: { id: args.collectionId },
data: { products: { disconnect: args.productIds.map(id => ({ id })) } },
})
return collection
},
})
t.field('createProduct', 'Product', {
args: {
data: arg('CreateProductInput', { required: true }),
},
resolve: async (parent, { data }, ctx) => {
return ctx.prisma.createProduct({
name: data.name,
brand: { connect: { id: data.brand.id } },
attributes: {
connect: data.attributesIds,
},
variants: {
create: data.variants.map(
variant =>
({
optionValues: {
connect: variant.optionsValueIds,
},
} as VariantCreateInput),
return acc
}
if (fieldArg.type.isInput) {
typesToExport.push(
...exportInputObjectType(
typesMap.types[fieldArg.type.name],
typesMap,
{},
),
)
} else if (fieldArg.type.isEnum) {
typesToExport.push(exportEnumType(typesMap.enums[fieldArg.type.name]))
}
acc[fieldArg.name] = arg(
fieldArg.type.name as any,
typeToFieldOpts(fieldArg.type),
)
return acc
},
{},
(acc, fieldArg) => {
acc[fieldArg.name] = arg(fieldArg.type.name as any, {
...typeToFieldOpts(fieldArg.type),
})
return acc
},
{},