Skip to content

Commit c88d0b1

Browse files
authored
Merge pull request #54 from Shopify/include-declarative-definition
Feature: Include declarative product metafield
2 parents d87fb9c + 8cde649 commit c88d0b1

4 files changed

Lines changed: 37 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# @shopify/shopify-app-template-react-router
22

3+
## 2025.09.26
4+
5+
- [#54](https://github.com/Shopify/shopify-app-template-react-router/pull/54) Includes a declarative product metafield definition
6+
37
## 2025.08.17
48

59
- [#58](https://github.com/Shopify/shopify-app-template-react-router/pull/58) Update Shopify & React Router dependencies. Use Shopify React Router in graphqlrc, not shopify-api

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ This template comes pre-configured with examples of:
7373
1. Setting up your Shopify app in [/app/shopify.server.ts](https://github.com/Shopify/shopify-app-template-react-router/blob/main/app/shopify.server.ts)
7474
2. Querying data using Graphql. Please see: [/app/routes/app.\_index.tsx](https://github.com/Shopify/shopify-app-template-react-router/blob/main/app/routes/app._index.tsx).
7575
3. Responding to webhooks. Please see [/app/routes/webhooks.tsx](https://github.com/Shopify/shopify-app-template-react-router/blob/main/app/routes/webhooks.app.uninstalled.tsx).
76+
4. Using metafields and declarative metafield definitions. Please see [/app/routes/app.\_index.tsx](https://github.com/Shopify/shopify-app-template-react-router/blob/main/app/routes/app._index.tsx) and [/shopify.app.toml](https://github.com/Shopify/shopify-app-template-react-router/blob/main/shopify.app.toml).
7677

7778
Please read the [documentation for @shopify/shopify-app-react-router](https://shopify.dev/docs/api/shopify-app-react-router) to see what other API's are available.
7879

@@ -155,7 +156,7 @@ This only applies if your app is embedded, which it will be by default.
155156

156157
### Webhooks: shop-specific webhook subscriptions aren't updated
157158

158-
If you are registering webhooks in the `afterAuth` hook, using `shopify.registerWebhooks`, you may find that your subscriptions aren't being updated.
159+
If you are registering webhooks in the `afterAuth` hook, using `shopify.registerWebhooks`, you may find that your subscriptions aren't being updated.
159160

160161
Instead of using the `afterAuth` hook declare app-specific webhooks in the `shopify.app.toml` file. This approach is easier since Shopify will automatically sync changes every time you run `deploy` (e.g: `npm run deploy`). Please read these guides to understand more:
161162

@@ -171,7 +172,7 @@ During normal development, the app won't need to re-authenticate most of the tim
171172

172173
### Webhooks: Admin created webhook failing HMAC validation
173174

174-
Webhooks subscriptions created in the [Shopify admin](https://help.shopify.com/en/manual/orders/notifications/webhooks) will fail HMAC validation. This is because the webhook payload is not signed with your app's secret key.
175+
Webhooks subscriptions created in the [Shopify admin](https://help.shopify.com/en/manual/orders/notifications/webhooks) will fail HMAC validation. This is because the webhook payload is not signed with your app's secret key.
175176

176177
The recommended solution is to use [app-specific webhooks](https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-subscriptions) defined in your toml file instead. Test your webhooks by triggering events manually in the Shopify admin(e.g. Updating the product title to trigger a `PRODUCTS_UPDATE`).
177178

app/routes/app._index.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,21 @@ export const action = async ({ request }: ActionFunctionArgs) => {
3939
}
4040
}
4141
}
42+
demoInfo: metafield(namespace: "$app", key: "demo_info") { jsonValue }
4243
}
4344
}
4445
}`,
4546
{
4647
variables: {
4748
product: {
4849
title: `${color} Snowboard`,
50+
metafields: [
51+
{
52+
namespace: "$app",
53+
key: "demo_info",
54+
value: `Created by React Router Template`,
55+
},
56+
],
4957
},
5058
},
5159
},
@@ -140,7 +148,12 @@ export default function Index() {
140148
>
141149
productCreate
142150
</s-link>{" "}
143-
mutation in our API references.
151+
mutation in our API references. Includes a product <s-link
152+
href="https://shopify.dev/docs/apps/build/custom-data/metafields/manage-metafields"
153+
target="_blank"
154+
>
155+
metafield
156+
</s-link>.
144157
</s-paragraph>
145158
<s-stack direction="inline" gap="base">
146159
<s-button
@@ -214,6 +227,15 @@ export default function Index() {
214227
GraphQL
215228
</s-link>
216229
</s-paragraph>
230+
<s-paragraph>
231+
<s-text>API: </s-text>
232+
<s-link
233+
href="https://shopify.dev/docs/apps/build/custom-data"
234+
target="_blank"
235+
>
236+
Metafields & metaobjects
237+
</s-link>
238+
</s-paragraph>
217239
<s-paragraph>
218240
<s-text>Database: </s-text>
219241
<s-link href="https://www.prisma.io/" target="_blank">

shopify.app.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
scopes = "write_products"
44

5+
# Product metafield for tracking demo products created by this template
6+
[product.metafields.app.demo_info]
7+
type = "single_line_text_field"
8+
name = "Demo Source Info"
9+
description = "Tracks products created by the Shopify app template for development"
10+
access.admin = "merchant_read_write"
11+
512
[webhooks]
613
api_version = "2025-07"
714

0 commit comments

Comments
 (0)