diff --git a/web/index.js b/web/index.js index 34099c3d..51b4181a 100644 --- a/web/index.js +++ b/web/index.js @@ -40,10 +40,19 @@ app.use("/api/*", shopify.validateAuthenticatedSession()); app.use(express.json()); app.get("/api/products/count", async (_req, res) => { - const countData = await shopify.api.rest.Product.count({ + const client = new shopify.api.clients.Graphql({ session: res.locals.shopify.session, }); - res.status(200).send(countData); + + const countData = await client.request(` + query shopifyProductCount { + productsCount { + count + } + } + `); + + res.status(200).send({ count: countData.data.productsCount.count }); }); app.post("/api/products", async (_req, res) => { diff --git a/web/package.json b/web/package.json index 906dbf90..c730caec 100644 --- a/web/package.json +++ b/web/package.json @@ -13,8 +13,8 @@ "node": ">=16.13.0" }, "dependencies": { - "@shopify/shopify-app-express": "^2.1.3", - "@shopify/shopify-app-session-storage-sqlite": "^1.2.3", + "@shopify/shopify-app-express": "^5.0.4", + "@shopify/shopify-app-session-storage-sqlite": "^4.0.4", "compression": "^1.7.4", "cross-env": "^7.0.3", "serve-static": "^1.14.1" diff --git a/web/product-creator.js b/web/product-creator.js index d0a06bfd..7c3219fc 100644 --- a/web/product-creator.js +++ b/web/product-creator.js @@ -88,14 +88,10 @@ export default async function productCreator( try { for (let i = 0; i < count; i++) { - await client.query({ - data: { - query: CREATE_PRODUCTS_MUTATION, - variables: { - input: { - title: `${randomTitle()}`, - variants: [{ price: randomPrice() }], - }, + await client.request(CREATE_PRODUCTS_MUTATION, { + variables: { + input: { + title: `${randomTitle()}`, }, }, }); @@ -116,7 +112,3 @@ function randomTitle() { const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)]; return `${adjective} ${noun}`; } - -function randomPrice() { - return Math.round((Math.random() * 10 + Number.EPSILON) * 100) / 100; -} diff --git a/web/shopify.js b/web/shopify.js index 500a8022..87c73721 100644 --- a/web/shopify.js +++ b/web/shopify.js @@ -1,7 +1,7 @@ import { BillingInterval, LATEST_API_VERSION } from "@shopify/shopify-api"; import { shopifyApp } from "@shopify/shopify-app-express"; import { SQLiteSessionStorage } from "@shopify/shopify-app-session-storage-sqlite"; -import { restResources } from "@shopify/shopify-api/rest/admin/2023-04"; +import { restResources } from "@shopify/shopify-api/rest/admin/2024-07"; const DB_PATH = `${process.cwd()}/database.sqlite`; @@ -20,6 +20,11 @@ const shopify = shopifyApp({ api: { apiVersion: LATEST_API_VERSION, restResources, + future: { + customerAddressDefaultFix: true, + lineItemBilling: true, + unstable_managedPricingSupport: true, + }, billing: undefined, // or replace with billingConfig above to enable example billing }, auth: {