Syncing Product Table First Immediately after Install

In order to onboard on our app, a newly installed merchant store's products need to be fully synced. We've noticed it could take up to 2 mins to sync the merchant immediately after install causing a bad experience for the merchant. We use api.shopifySync.run (see below). 1. Is this the right API to use or is the bulk api better? 2. Is there a way to prioritize syncing the product table first so merchant is unblocked from onboarding.
await api.shopifySync.run({
shopifySync: {
domain: record.domain,
shop: {
_link: record.id,
},
},
});
await api.shopifySync.run({
shopifySync: {
domain: record.domain,
shop: {
_link: record.id,
},
},
});
4 Replies
Simon
Simon2mo ago
You can sync models specifically:
const sync = await api.shopifySync.run({
shopifySync: {
domain: record.domain,
shop: {
_link: record.id,
},
models: [
"shopifyProduct",
"shopifyProductVariant",
"shopifyCollection",
"shopifyInventoryItem",
"shopifyLocation",
"shopifyProductMedia",
"shopifyFile",
],
},
});
const sync = await api.shopifySync.run({
shopifySync: {
domain: record.domain,
shop: {
_link: record.id,
},
models: [
"shopifyProduct",
"shopifyProductVariant",
"shopifyCollection",
"shopifyInventoryItem",
"shopifyLocation",
"shopifyProductMedia",
"shopifyFile",
],
},
});
You could check for the sync to complete (polling?) and then schedule the next. Don't think you can enqueue syncs. Personally, I show a banner in our apps while the first sync is running and block certain functionality. Using live query.
evidanary
evidanaryOP2mo ago
@Simon have you used the bulkRun api - is it better for such uses cases ChatGPT recommended something like :
import { ShopifySync } from "gadget-server";

await ShopifySync.bulkRun("shopifyProduct", {
shop: record, // this is your Shopify shop record
});
import { ShopifySync } from "gadget-server";

await ShopifySync.bulkRun("shopifyProduct", {
shop: record, // this is your Shopify shop record
});
ljspoor94
ljspoor942mo ago
Where did you find this bulk run? I don't think thats even a thing. And anyway, Gadget will most likely can't do it any faster as Shopify has rate limits
Simon
Simon2mo ago
Agreed @ljspoor94, that's not a gadget thing. What gpt might be referring to is shopify bulkQeury. You could theortically spin one up yourself. It runs outside of the shopify rate limits, but you need to implement it yourself (initiate bulk query, poll for status or use your own webhook, get the data (JsonL), parse it, create records in gadget... See also https://discord.com/channels/836317518595096598/1364902392671371306/1374311324414382124, but haven't done that myself... And it's not magic either, it still takes it time + for huuuge stores it could even fail bcs it times out after 10min... guess not an issue for products though.

Did you find this page helpful?