Skip to content

Commit 82636c1

Browse files
authored
Merge pull request #126 from gadget-inc/pq-media
Product quiz, product media
2 parents b986cfa + 6c1cb6a commit 82636c1

File tree

23 files changed

+179
-136
lines changed

23 files changed

+179
-136
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
filter ($session: Session) on ShopifyFile [
2+
where shopId == $session.shopId
3+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
filter ($session: Session) on ShopifyProductMedia [
2+
where shopId == $session.shopId
3+
]

shopify/product-quiz-template/accessControl/filters/shopifyProductImage/shopifyProductImage.gelly

Lines changed: 0 additions & 5 deletions
This file was deleted.

shopify/product-quiz-template/accessControl/permissions.gadget.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export const permissions: GadgetPermissions = {
5959
"accessControl/filters/shopifyAsset/shopifyAsset.gelly",
6060
},
6161
},
62+
shopifyFile: {
63+
read: {
64+
filter: "accessControl/filters/shopify/shopifyFile.gelly",
65+
},
66+
},
6267
shopifyGdprRequest: {
6368
read: {
6469
filter:
@@ -75,10 +80,10 @@ export const permissions: GadgetPermissions = {
7580
"accessControl/filters/shopifyProduct/shopifyProduct.gelly",
7681
},
7782
},
78-
shopifyProductImage: {
83+
shopifyProductMedia: {
7984
read: {
8085
filter:
81-
"accessControl/filters/shopifyProductImage/shopifyProductImage.gelly",
86+
"accessControl/filters/shopify/shopifyProductMedia.gelly",
8287
},
8388
},
8489
shopifyShop: {
@@ -135,9 +140,6 @@ export const permissions: GadgetPermissions = {
135140
shopifyProduct: {
136141
read: true,
137142
},
138-
shopifyProductImage: {
139-
read: true,
140-
},
141143
shopperSuggestion: {
142144
actions: {
143145
create: true,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { applyParams, save, ActionOptions } from "gadget-server";
2+
import { preventCrossShopDataAccess } from "gadget-server/shopify";
3+
4+
export const run: ActionRun = async ({ params, record, logger, api, connections }) => {
5+
applyParams(params, record);
6+
await preventCrossShopDataAccess(params, record);
7+
await save(record);
8+
};
9+
10+
export const onSuccess: ActionOnSuccess = async ({ params, record, logger, api, connections }) => {
11+
// Your logic goes here
12+
};
13+
14+
export const options: ActionOptions = { actionType: "create" };
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { deleteRecord, ActionOptions } from "gadget-server";
2+
import { preventCrossShopDataAccess } from "gadget-server/shopify";
3+
4+
export const run: ActionRun = async ({ params, record, logger, api, connections }) => {
5+
await preventCrossShopDataAccess(params, record);
6+
await deleteRecord(record);
7+
};
8+
9+
export const onSuccess: ActionOnSuccess = async ({ params, record, logger, api, connections }) => {
10+
// Your logic goes here
11+
};
12+
13+
export const options: ActionOptions = { actionType: "delete" };
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { applyParams, save, ActionOptions } from "gadget-server";
2+
import { preventCrossShopDataAccess } from "gadget-server/shopify";
3+
4+
export const run: ActionRun = async ({ params, record, logger, api, connections }) => {
5+
applyParams(params, record);
6+
await preventCrossShopDataAccess(params, record);
7+
await save(record);
8+
};
9+
10+
export const onSuccess: ActionOnSuccess = async ({ params, record, logger, api, connections }) => {
11+
// Your logic goes here
12+
};
13+
14+
export const options: ActionOptions = { actionType: "update" };
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { GadgetModel } from "gadget-server";
2+
3+
// This file describes the schema for the "shopifyFile" model, go to https://product-quiz-template.gadget.app/edit to view/edit your model in Gadget
4+
// For more information on how to update this file http://docs.gadget.dev
5+
6+
export const schema: GadgetModel = {
7+
type: "gadget/model-schema/v1",
8+
storageKey: "DataModel-Shopify-File",
9+
fields: {},
10+
shopify: {
11+
fields: [
12+
"alt",
13+
"boundingBox",
14+
"duration",
15+
"embedUrl",
16+
"fileErrors",
17+
"fileStatus",
18+
"filename",
19+
"host",
20+
"image",
21+
"mediaContentType",
22+
"mediaErrors",
23+
"mediaWarnings",
24+
"mimetype",
25+
"originUrl",
26+
"originalFileSize",
27+
"originalSource",
28+
"preview",
29+
"product",
30+
"shop",
31+
"shopifyCreatedAt",
32+
"shopifyUpdatedAt",
33+
"sources",
34+
"status",
35+
"type",
36+
"url",
37+
],
38+
},
39+
};

shopify/product-quiz-template/api/models/shopifyProduct/schema.gadget.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export const schema: GadgetModel = {
77
type: "gadget/model-schema/v1",
88
storageKey: "DataModel-Shopify-Product",
99
fields: {
10+
category: {
11+
type: "json",
12+
storageKey:
13+
"ModelField-DataModel-Shopify-Product-__gadget_graphql_category::FieldStorageEpoch-DataModel-Shopify-Product-__gadget_graphql_category-initial",
14+
},
1015
publishedScope: {
1116
type: "string",
1217
storageKey:
@@ -39,10 +44,9 @@ export const schema: GadgetModel = {
3944
shopify: {
4045
fields: [
4146
"body",
42-
"category",
4347
"compareAtPriceRange",
4448
"handle",
45-
"images",
49+
"media",
4650
"productCategory",
4751
"productType",
4852
"publishedAt",

shopify/product-quiz-template/api/models/shopifyProductImage/actions/create.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)