import { ActionOptions, applyParams, save } from 'gadget-server';
import { preventCrossShopDataAccess } from 'gadget-server/shopify';
/** @type { ActionRun } */
export const run = async ({ params, record, logger, api, connections }) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);
await save(record);
};
/** @type { ActionOnSuccess } */
export const onSuccess = async ({ params, record, logger, api, connections }) => {
const shopify = await connections.shopify.forShopId('87443374404');
const variant = await shopify.graphql(
`query {
productVariant(id: $id) {
id
title
}
}`,
{
id: `gid://shopify/ProductVariant/${record.id}`
}
);
logger.info({ variant }, 'Retrieved variant from Shopify');
};
/** @type { ActionOptions } */
export const options = {
actionType: 'custom',
triggers: {
api: true
}
};
import { ActionOptions, applyParams, save } from 'gadget-server';
import { preventCrossShopDataAccess } from 'gadget-server/shopify';
/** @type { ActionRun } */
export const run = async ({ params, record, logger, api, connections }) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);
await save(record);
};
/** @type { ActionOnSuccess } */
export const onSuccess = async ({ params, record, logger, api, connections }) => {
const shopify = await connections.shopify.forShopId('87443374404');
const variant = await shopify.graphql(
`query {
productVariant(id: $id) {
id
title
}
}`,
{
id: `gid://shopify/ProductVariant/${record.id}`
}
);
logger.info({ variant }, 'Retrieved variant from Shopify');
};
/** @type { ActionOptions } */
export const options = {
actionType: 'custom',
triggers: {
api: true
}
};