🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@kontakta/cloud-code-directives

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kontakta/cloud-code-directives - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+1
-1
package.json
{
"name": "@kontakta/cloud-code-directives",
"version": "1.0.0",
"version": "1.0.1",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",

@@ -51,3 +51,3 @@ import rename from 'deep-rename-keys';

export async function fetchFullProduct(productId: string, variantId: string, originObject: any) {
export async function fetchFullProduct(productId: string, variantId: string | null, originObject: any) {
try {

@@ -58,3 +58,3 @@ let result;

const prod = await new Parse.Query('Product')
.include(['store', 'images'])
.include(['categories', 'catalog'])
.equalTo('objectId', productId)

@@ -66,3 +66,3 @@ .first({ useMasterKey: true });

const product = await new Parse.Query('Product')
.include('store')
.include(['categories', 'catalog'])
.equalTo('objectId', productId)

@@ -74,3 +74,3 @@ .first({ useMasterKey: true });

return result ? { ...originObject, ...result } : null;
return result ? { ...result, ...originObject, orderQuantity: originObject.quantity } : null;
} catch (error) {

@@ -77,0 +77,0 @@ // TODO: report

@@ -8,3 +8,3 @@ import { defaultFieldResolver, GraphQLFieldConfig } from 'graphql';

unknown,
{ productKey: string; variantKey: string }
{ id: string; parentId: string }
>

@@ -21,4 +21,2 @@ ) {

const { productKey, variantKey } = params[1];
if (!result) return result;

@@ -30,5 +28,8 @@

const promises = result.map((r) =>
fetchFullProduct(r[productKey] as string, r[variantKey] as string, r)
);
const promises = result.map((r) => {
const variantId = !r.parentId || r.parentId === 'root' ? null : r.id as string;
const productId = !r.parentId || r.parentId === 'root' ? r.id as string : r.parentId as string;
return fetchFullProduct(productId, variantId, r);
});
const fetched = await Promise.all(promises);

@@ -35,0 +36,0 @@ return fetched.filter((f) => !!f);