Skip to content

Commit

Permalink
Update Shopify dependencies to latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomarg committed Aug 28, 2024
1 parent 709814d commit 27810fe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
13 changes: 11 additions & 2 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 4 additions & 12 deletions web/product-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`,
},
},
});
Expand All @@ -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;
}
7 changes: 6 additions & 1 deletion web/shopify.js
Original file line number Diff line number Diff line change
@@ -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`;

Expand All @@ -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: {
Expand Down

0 comments on commit 27810fe

Please sign in to comment.