Skip to content

Commit 0d6aa76

Browse files
committed
Add Liquid templating for delivery customization tutorial app
1 parent cbfe3eb commit 0d6aa76

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

sample-apps/delivery-customizations/extensions/delivery-customization/input.graphql renamed to sample-apps/delivery-customizations/extensions/delivery-customization/input.graphql.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ query Input {
1212
}
1313
deliveryCustomization {
1414
metafield(
15-
namespace: "delivery-customization"
15+
namespace: "{{ app_name | replace: " ", "-" | downcase }}"
1616
key: "function-configuration"
1717
) {
1818
value

sample-apps/delivery-customizations/web/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import shopify from "./shopify.js";
88
import productCreator from "./product-creator.js";
99
import GDPRWebhookHandlers from "./gdpr.js";
1010
import { GraphqlQueryError } from "@shopify/shopify-api";
11+
import metafields from "./metafields.js";
1112

1213
const PORT = parseInt(process.env.BACKEND_PORT || process.env.PORT, 10);
1314

@@ -58,7 +59,7 @@ app.get("/api/deliveryCustomization/:id", async (req, res) => {
5859
query: `query DeliveryCustomization($id: ID!) {
5960
deliveryCustomization(id: $id) {
6061
id
61-
metafield(namespace: "delivery-customization", key: "function-configuration") {
62+
metafield(namespace: "${metafields.namespace}", key: "${metafields.key}") {
6263
value
6364
}
6465
}
@@ -134,8 +135,8 @@ app.put("/api/deliveryCustomization/update", async (req, res) => {
134135
metafieldsSet(metafields: [
135136
{
136137
ownerId: $customizationId
137-
namespace: "delivery-customization"
138-
key: "function-configuration"
138+
namespace: "${metafields.namespace}"
139+
key: "${metafields.key}"
139140
value: $configurationValue
140141
type: "json"
141142
}
@@ -215,8 +216,8 @@ app.post("/api/deliveryCustomization/create", async (req, res) => {
215216
metafieldsSet(metafields: [
216217
{
217218
ownerId: $customizationId
218-
namespace: "delivery-customization"
219-
key: "function-configuration"
219+
namespace: "${metafields.namespace}"
220+
key: "${metafields.key}"
220221
value: $configurationValue
221222
type: "json"
222223
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
namespace: '{{ app_name | replace: " ", "-" | downcase }}',
3+
key: "function-configuration",
4+
};

0 commit comments

Comments
 (0)