Shopify Product

This page documents the Shopify Product model.

Data Shape

Gadget's database stores Shopify Product records by storing and retrieving each of the fields defined on the model in the Gadget Editor to a managed database. Gadget has generated a GraphQL type matching the configured fields for Shopify Product:

Shopify Product Schema
1export interface ShopifyProduct {
2 __typename: "ShopifyProduct";
3
4 /** The globally unique, unchanging identifier for this record. Assigned and managed by Gadget. */
5 id: Scalars["GadgetID"];
6
7 /** The time at which this record was first created. Set once upon record creation and never changed. Managed by Gadget. */
8 createdAt: Scalars["DateTime"];
9
10 /** The time at which this record was last changed. Set each time the record is successfully acted upon by an action. Managed by Gadget. */
11 updatedAt: Scalars["DateTime"];
12
13 /** The current state this record is in. Changed by invoking actions. Managed by Gadget. */
14 state: Scalars["RecordState"];
15
16 body: Scalars["String"] | null;
17
18 handle: Scalars["String"] | null;
19
20 images: ShopifyProductImageConnection;
21
22 productType: Scalars["String"] | null;
23
24 publishedAt: Scalars["DateTime"] | null;
25
26 publishedScope: Scalars["String"] | null;
27
28 shopifyCreatedAt: Scalars["DateTime"] | null;
29
30 tags: Scalars["JSON"] | null;
31
32 shopifyUpdatedAt: Scalars["DateTime"] | null;
33
34 templateSuffix: Scalars["String"] | null;
35
36 title: Scalars["String"] | null;
37
38 variants: ShopifyProductVariantConnection;
39
40 vendor: Scalars["String"] | null;
41
42 shop: ShopifyShop | null;
43
44 shopId: Scalars["GadgetID"] | null;
45
46 /** Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower. */
47 _all: Scalars["JSONObject"];
48}
1type ShopifyProduct {
2 """
3 The globally unique, unchanging identifier for this record. Assigned and managed by Gadget.
4 """
5 id: GadgetID!
6
7 """
8 The time at which this record was first created. Set once upon record creation and never changed. Managed by Gadget.
9 """
10 createdAt: DateTime!
11
12 """
13 The time at which this record was last changed. Set each time the record is successfully acted upon by an action. Managed by Gadget.
14 """
15 updatedAt: DateTime!
16
17 """
18 The current state this record is in. Changed by invoking actions. Managed by Gadget.
19 """
20 state: RecordState!
21 body: String
22 handle: String
23 images(
24 """
25 Returns the items in the list that come after the specified cursor.
26 """
27 after: String
28
29 """
30 Returns the first n items from the list.
31 """
32 first: Int
33
34 """
35 Returns the items in the list that come before the specified cursor.
36 """
37 before: String
38
39 """
40 Returns the last n items from the list.
41 """
42 last: Int
43
44 """
45 A list of sort orders to return the results in
46 """
47 sort: [ShopifyProductImageSort!]
48
49 """
50 A list of filters to refine the results by
51 """
52 filter: [ShopifyProductImageFilter!]
53
54 """
55 A free form text search query to find records matching
56 """
57 search: String
58 ): ShopifyProductImageConnection!
59 productType: String
60 publishedAt: DateTime
61 publishedScope: String
62 shopifyCreatedAt: DateTime
63 tags: JSON
64 shopifyUpdatedAt: DateTime
65 templateSuffix: String
66 title: String
67 variants(
68 """
69 Returns the items in the list that come after the specified cursor.
70 """
71 after: String
72
73 """
74 Returns the first n items from the list.
75 """
76 first: Int
77
78 """
79 Returns the items in the list that come before the specified cursor.
80 """
81 before: String
82
83 """
84 Returns the last n items from the list.
85 """
86 last: Int
87
88 """
89 A list of sort orders to return the results in
90 """
91 sort: [ShopifyProductVariantSort!]
92
93 """
94 A list of filters to refine the results by
95 """
96 filter: [ShopifyProductVariantFilter!]
97
98 """
99 A free form text search query to find records matching
100 """
101 search: String
102 ): ShopifyProductVariantConnection!
103 vendor: String
104 shop: ShopifyShop
105 shopId: GadgetID
106
107 """
108 Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower.
109 """
110 _all: JSONObject!
111}

You can preview what a real record's shape looks like by fetching it using the alida-quiz-app-2 API Playground.

Any fetched Shopify Product record will have this same ShopifyProduct type, and expose the same data by default, regardless of if it's fetched by ID or as part of a findMany. This means you can select any of the record's fields wherever you like in a GraphQL query according to the use case at hand.

Retrieving one Shopify Product record

Individual Shopify Product records can be retrieved using the "find by ID" API endpoint. You can also return only some fields, or extra fields beyond what Gadget retrieves by default, using the select option.

The findOne function throws an error if no matching record is found, which you will need to catch and handle. Alternatively, you can use the maybeFindOne function, which returns null if no record is found, without throwing an error.

Similarly, the useFindOne React hook returns (but does not throw) an error when no matching record is found, while the useMaybeFindOne hook simply returns null if no record is found, without also returning an error.

Get one Shopify Product
const shopifyProductRecord = await api.shopifyProduct.findOne("some-id");
console.log(shopifyProductRecord.id); //=> a string
console.log(shopifyProductRecord.createdAt); //=> a Date object
const [result, refresh] = useFindOne(api.shopifyProduct, "some-id");
const { data, error, fetching } = result;
console.log(data?.id); //=> a string
console.log(data?.createdAt); //=> a Date object
1query GetOneShopifyProduct($id: GadgetID!) {
2 shopifyProduct(id: $id) {
3 __typename
4 id
5 state
6 body
7 createdAt
8 handle
9 images {
10 edges {
11 node {
12 id
13 state
14 createdAt
15 height
16 position
17 product {
18 id
19 state
20 body
21 createdAt
22 handle
23 productType
24 publishedAt
25 publishedScope
26 shopifyCreatedAt
27 shopifyUpdatedAt
28 tags
29 templateSuffix
30 title
31 updatedAt
32 vendor
33 }
34 shop {
35 id
36 state
37 accessToken
38 address1
39 address2
40 checkoutApiSupported
41 city
42 cookieConsentLevel
43 country
44 countryCode
45 countryName
46 countyTaxes
47 createdAt
48 currency
49 customerEmail
50 domain
51 eligibleForCardReaderGiveaway
52 eligibleForPayments
53 email
54 enabledPresentmentCurrencies
55 finances
56 forceSsl
57 googleAppsDomain
58 googleAppsLoginEnabled
59 grantedScopes
60 hasDiscounts
61 hasGiftCards
62 hasStorefront
63 ianaTimezone
64 installedViaApiKey
65 latitude
66 longitude
67 moneyFormat
68 moneyInEmailsFormat
69 moneyWithCurrencyFormat
70 moneyWithCurrencyInEmailsFormat
71 multiLocationEnabled
72 myshopifyDomain
73 name
74 passwordEnabled
75 phone
76 planDisplayName
77 planName
78 preLaunchEnabled
79 primaryLocale
80 province
81 provinceCode
82 registeredWebhooks
83 requiresExtraPaymentsAgreement
84 setupRequired
85 shopOwner
86 shopifyCreatedAt
87 shopifyUpdatedAt
88 source
89 taxShipping
90 taxesIncluded
91 timezone
92 updatedAt
93 weightUnit
94 zipCode
95 }
96 shopifyCreatedAt
97 shopifyUpdatedAt
98 source
99 updatedAt
100 width
101 }
102 }
103 }
104 productType
105 publishedAt
106 publishedScope
107 shop {
108 id
109 state
110 accessToken
111 address1
112 address2
113 checkoutApiSupported
114 city
115 cookieConsentLevel
116 country
117 countryCode
118 countryName
119 countyTaxes
120 createdAt
121 currency
122 customerEmail
123 domain
124 eligibleForCardReaderGiveaway
125 eligibleForPayments
126 email
127 enabledPresentmentCurrencies
128 finances
129 forceSsl
130 googleAppsDomain
131 googleAppsLoginEnabled
132 grantedScopes
133 hasDiscounts
134 hasGiftCards
135 hasStorefront
136 ianaTimezone
137 installedViaApiKey
138 latitude
139 longitude
140 moneyFormat
141 moneyInEmailsFormat
142 moneyWithCurrencyFormat
143 moneyWithCurrencyInEmailsFormat
144 multiLocationEnabled
145 myshopifyDomain
146 name
147 passwordEnabled
148 phone
149 planDisplayName
150 planName
151 preLaunchEnabled
152 primaryLocale
153 province
154 provinceCode
155 registeredWebhooks
156 requiresExtraPaymentsAgreement
157 setupRequired
158 shopOwner
159 shopifyCreatedAt
160 shopifyUpdatedAt
161 source
162 taxShipping
163 taxesIncluded
164 timezone
165 updatedAt
166 weightUnit
167 zipCode
168 }
169 shopifyCreatedAt
170 shopifyUpdatedAt
171 tags
172 templateSuffix
173 title
174 updatedAt
175 variants {
176 edges {
177 node {
178 id
179 state
180 barcode
181 compareAtPrice
182 createdAt
183 fulfillmentService
184 grams
185 inventoryManagement
186 inventoryPolicy
187 inventoryQuantity
188 inventoryQuantityAdjustment
189 oldInventoryQuantity
190 option1
191 option2
192 option3
193 position
194 presentmentPrices
195 price
196 product {
197 id
198 state
199 body
200 createdAt
201 handle
202 productType
203 publishedAt
204 publishedScope
205 shopifyCreatedAt
206 shopifyUpdatedAt
207 tags
208 templateSuffix
209 title
210 updatedAt
211 vendor
212 }
213 productImage {
214 id
215 state
216 createdAt
217 height
218 position
219 shopifyCreatedAt
220 shopifyUpdatedAt
221 source
222 updatedAt
223 width
224 }
225 requiresShipping
226 shop {
227 id
228 state
229 accessToken
230 address1
231 address2
232 checkoutApiSupported
233 city
234 cookieConsentLevel
235 country
236 countryCode
237 countryName
238 countyTaxes
239 createdAt
240 currency
241 customerEmail
242 domain
243 eligibleForCardReaderGiveaway
244 eligibleForPayments
245 email
246 enabledPresentmentCurrencies
247 finances
248 forceSsl
249 googleAppsDomain
250 googleAppsLoginEnabled
251 grantedScopes
252 hasDiscounts
253 hasGiftCards
254 hasStorefront
255 ianaTimezone
256 installedViaApiKey
257 latitude
258 longitude
259 moneyFormat
260 moneyInEmailsFormat
261 moneyWithCurrencyFormat
262 moneyWithCurrencyInEmailsFormat
263 multiLocationEnabled
264 myshopifyDomain
265 name
266 passwordEnabled
267 phone
268 planDisplayName
269 planName
270 preLaunchEnabled
271 primaryLocale
272 province
273 provinceCode
274 registeredWebhooks
275 requiresExtraPaymentsAgreement
276 setupRequired
277 shopOwner
278 shopifyCreatedAt
279 shopifyUpdatedAt
280 source
281 taxShipping
282 taxesIncluded
283 timezone
284 updatedAt
285 weightUnit
286 zipCode
287 }
288 shopifyCreatedAt
289 shopifyUpdatedAt
290 sku
291 taxCode
292 taxable
293 title
294 updatedAt
295 weight
296 weightUnit
297 }
298 }
299 }
300 vendor
301 }
302}
Variables
json
{
"id": "some-id"
}

Retrieving the first of many Shopify Product records

The first record from a list of records can be retrieved using the "find first" API endpoint. The source list of records can be filtered using the filter option, sorted using the sort option, searched using the search option, though no pagination options are available on this endpoint. You can also return only some fields, or extra fields beyond what Gadget retrieves by default using the select option.

The findFirst function throws an error if no matching record is found, which you will need to catch and handle. Alternatively, you can use the maybeFindFirst function, which returns null if no record is found, without throwing an error.

Similarly, the useFindFirst React hook returns (but does not throw) an error when no matching record is found, while the useMaybeFindFirst hook simply returns null if no record is found, without also returning an error.

Get one Shopify Product
const shopifyProductRecord = await api.shopifyProduct.findFirst();
console.log(shopifyProductRecord.id); //=> a string
console.log(shopifyProductRecord.createdAt); //=> a Date object
const [result, refresh] = useFindFirst(api.shopifyProduct);
const { data, error, fetching } = result;
console.log(data?.id); //=> a string
console.log(data?.createdAt); //=> a Date object
1query FindManyShopifyProducts(
2 $first: Int
3 $search: String
4 $sort: [ShopifyProductSort!]
5 $filter: [ShopifyProductFilter!]
6) {
7 shopifyProducts(first: $first, search: $search, sort: $sort, filter: $filter) {
8 edges {
9 node {
10 __typename
11 id
12 state
13 body
14 createdAt
15 handle
16 images {
17 edges {
18 node {
19 id
20 state
21 createdAt
22 height
23 position
24 product {
25 id
26 state
27 body
28 createdAt
29 handle
30 productType
31 publishedAt
32 publishedScope
33 shopifyCreatedAt
34 shopifyUpdatedAt
35 tags
36 templateSuffix
37 title
38 updatedAt
39 vendor
40 }
41 shop {
42 id
43 state
44 accessToken
45 address1
46 address2
47 checkoutApiSupported
48 city
49 cookieConsentLevel
50 country
51 countryCode
52 countryName
53 countyTaxes
54 createdAt
55 currency
56 customerEmail
57 domain
58 eligibleForCardReaderGiveaway
59 eligibleForPayments
60 email
61 enabledPresentmentCurrencies
62 finances
63 forceSsl
64 googleAppsDomain
65 googleAppsLoginEnabled
66 grantedScopes
67 hasDiscounts
68 hasGiftCards
69 hasStorefront
70 ianaTimezone
71 installedViaApiKey
72 latitude
73 longitude
74 moneyFormat
75 moneyInEmailsFormat
76 moneyWithCurrencyFormat
77 moneyWithCurrencyInEmailsFormat
78 multiLocationEnabled
79 myshopifyDomain
80 name
81 passwordEnabled
82 phone
83 planDisplayName
84 planName
85 preLaunchEnabled
86 primaryLocale
87 province
88 provinceCode
89 registeredWebhooks
90 requiresExtraPaymentsAgreement
91 setupRequired
92 shopOwner
93 shopifyCreatedAt
94 shopifyUpdatedAt
95 source
96 taxShipping
97 taxesIncluded
98 timezone
99 updatedAt
100 weightUnit
101 zipCode
102 }
103 shopifyCreatedAt
104 shopifyUpdatedAt
105 source
106 updatedAt
107 width
108 }
109 }
110 }
111 productType
112 publishedAt
113 publishedScope
114 shop {
115 id
116 state
117 accessToken
118 address1
119 address2
120 checkoutApiSupported
121 city
122 cookieConsentLevel
123 country
124 countryCode
125 countryName
126 countyTaxes
127 createdAt
128 currency
129 customerEmail
130 domain
131 eligibleForCardReaderGiveaway
132 eligibleForPayments
133 email
134 enabledPresentmentCurrencies
135 finances
136 forceSsl
137 googleAppsDomain
138 googleAppsLoginEnabled
139 grantedScopes
140 hasDiscounts
141 hasGiftCards
142 hasStorefront
143 ianaTimezone
144 installedViaApiKey
145 latitude
146 longitude
147 moneyFormat
148 moneyInEmailsFormat
149 moneyWithCurrencyFormat
150 moneyWithCurrencyInEmailsFormat
151 multiLocationEnabled
152 myshopifyDomain
153 name
154 passwordEnabled
155 phone
156 planDisplayName
157 planName
158 preLaunchEnabled
159 primaryLocale
160 province
161 provinceCode
162 registeredWebhooks
163 requiresExtraPaymentsAgreement
164 setupRequired
165 shopOwner
166 shopifyCreatedAt
167 shopifyUpdatedAt
168 source
169 taxShipping
170 taxesIncluded
171 timezone
172 updatedAt
173 weightUnit
174 zipCode
175 }
176 shopifyCreatedAt
177 shopifyUpdatedAt
178 tags
179 templateSuffix
180 title
181 updatedAt
182 variants {
183 edges {
184 node {
185 id
186 state
187 barcode
188 compareAtPrice
189 createdAt
190 fulfillmentService
191 grams
192 inventoryManagement
193 inventoryPolicy
194 inventoryQuantity
195 inventoryQuantityAdjustment
196 oldInventoryQuantity
197 option1
198 option2
199 option3
200 position
201 presentmentPrices
202 price
203 product {
204 id
205 state
206 body
207 createdAt
208 handle
209 productType
210 publishedAt
211 publishedScope
212 shopifyCreatedAt
213 shopifyUpdatedAt
214 tags
215 templateSuffix
216 title
217 updatedAt
218 vendor
219 }
220 productImage {
221 id
222 state
223 createdAt
224 height
225 position
226 shopifyCreatedAt
227 shopifyUpdatedAt
228 source
229 updatedAt
230 width
231 }
232 requiresShipping
233 shop {
234 id
235 state
236 accessToken
237 address1
238 address2
239 checkoutApiSupported
240 city
241 cookieConsentLevel
242 country
243 countryCode
244 countryName
245 countyTaxes
246 createdAt
247 currency
248 customerEmail
249 domain
250 eligibleForCardReaderGiveaway
251 eligibleForPayments
252 email
253 enabledPresentmentCurrencies
254 finances
255 forceSsl
256 googleAppsDomain
257 googleAppsLoginEnabled
258 grantedScopes
259 hasDiscounts
260 hasGiftCards
261 hasStorefront
262 ianaTimezone
263 installedViaApiKey
264 latitude
265 longitude
266 moneyFormat
267 moneyInEmailsFormat
268 moneyWithCurrencyFormat
269 moneyWithCurrencyInEmailsFormat
270 multiLocationEnabled
271 myshopifyDomain
272 name
273 passwordEnabled
274 phone
275 planDisplayName
276 planName
277 preLaunchEnabled
278 primaryLocale
279 province
280 provinceCode
281 registeredWebhooks
282 requiresExtraPaymentsAgreement
283 setupRequired
284 shopOwner
285 shopifyCreatedAt
286 shopifyUpdatedAt
287 source
288 taxShipping
289 taxesIncluded
290 timezone
291 updatedAt
292 weightUnit
293 zipCode
294 }
295 shopifyCreatedAt
296 shopifyUpdatedAt
297 sku
298 taxCode
299 taxable
300 title
301 updatedAt
302 weight
303 weightUnit
304 }
305 }
306 }
307 vendor
308 }
309 }
310 }
311}
Variables
json
{
"first": 1
}

Retrieving many Shopify Product records

Pages of Shopify Product records can be retrieved by using the "find many" API endpoint. The returned records can be filtered using the filter option, sorted using the sort option, searched using the search option, and paginated using standard Relay-style pagination options. You can also return only some fields, or extra fields beyond what Gadget retrieves by default using the select option.

This GraphQL endpoint returns records in the Relay Connection style (as a list of edges with nodes and cursors) so they can be paginated. The shopifyProducts GraphQL endpoint works with any Relay-compatible caching client, or you can use Gadget's JS client for pagination with the findMany function.

Find a page of Shopify Products

Fetch a page of records with the shopifyProduct.findMany JS method or the shopifyProducts GraphQL field. No options are required. The records returned will be implicitly sorted by ID ascending.

Find many Shopify Products
const shopifyProductRecords = await api.shopifyProduct.findMany();
console.log(shopifyProductRecords.length); //=> a number
console.log(shopifyProductRecords[0].id); //=> a string
const [result, refresh] = useFindMany(api.shopifyProduct);
const { data, error, fetching } = result;
console.log(data?.length); //=> a number
console.log(data?.[0].length); //=> a string
1query FindManyShopifyProducts {
2 shopifyProducts {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
{}

Sorting

Records can be sorted in the database to retrieve them in a certain order. Records are always implicitly sorted by ID ascending unless an explicit sort on the id field is defined. The GraphQL type ShopifyProductSort defines which fields can be sorted by.

Records can be sorted by multiple different fields and in multiple different directions by passing a list of ShopifyProductSort instead of just one.

GraphQL
1input ShopifyProductSort {
2 id: SortOrder
3 createdAt: SortOrder
4 updatedAt: SortOrder
5 state: SortOrder
6 body: SortOrder
7 handle: SortOrder
8 productType: SortOrder
9 publishedAt: SortOrder
10 publishedScope: SortOrder
11 shopifyCreatedAt: SortOrder
12 tags: SortOrder
13 shopifyUpdatedAt: SortOrder
14 templateSuffix: SortOrder
15 title: SortOrder
16 vendor: SortOrder
17}

Pass the sort option to the JS client, or the sort variable to a GraphQL query to sort the records returned.

Sort Shopify Product by most recently created
const shopifyProductRecords = await api.shopifyProduct.findMany({
sort: { createdAt: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifyProduct, {
sort: { createdAt: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($sort: [ShopifyProductSort!]) {
2 shopifyProducts(sort: $sort) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
{
"sort": {
"createdAt": "Descending"
}
}

Sort by multiple fields by passing an array of { [field]: "Ascending" | "Descending" } objects.

Sort Shopify Product by multiple fields
const shopifyProductRecords = await api.shopifyProduct.findMany({
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const [result, refresh] = useFindMany(api.shopifyProduct, {
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($sort: [ShopifyProductSort!]) {
2 shopifyProducts(sort: $sort) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
1{
2 "sort": [
3 {
4 "state": "Descending"
5 },
6 {
7 "createdAt": "Ascending"
8 }
9 ]
10}

All primitive field types in Gadget are sortable so you are able to sort by fields you have added to a model as well.

Sort Shopify Products by ID descending
const shopifyProductRecords = await api.shopifyProduct.findMany({
sort: { id: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifyProduct, {
sort: { id: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($sort: [ShopifyProductSort!]) {
2 shopifyProducts(sort: $sort) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
{
"sort": {
"id": "Descending"
}
}

Searching

Shopify Product records can be searched using Gadget's built in full text search functionality. Gadget search is appropriate for powering autocompletes, searchable tables, or other experiences where humans are writing search queries. It's typo tolerant, synonym aware and supports simple search operators like ! to exclude search terms.

Search Shopify Products by passing the search parameter with a search query string.

Search isn't field specific in Gadget -- all String or RichText field types are searched with the built in search functionality.

Full text search Shopify Products
const shopifyProductRecords = await api.shopifyProduct.findMany({
search: "a specific phrase to search for",
});
const [result, refresh] = useFindMany(api.shopifyProduct, {
search: "a specific phrase to search for",
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($search: String) {
2 shopifyProducts(search: $search) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
{
"search": "a specific phrase to search for"
}

Filtering

Shopify Product records can be filtered to return only the appropriate records. Records can be filtered on any field, including those managed by Gadget or fields added by developers. Filters can be combined with sorts, searches and paginated using cursor based Relay pagination.

Filter Shopify Products by passing the filter parameter with a filter object. Filter objects are nestable boolean conditions expressed as JS objects capturing a key, an operator, and usually a value.

The GraphQL type ShopifyProductFilter defines which fields can be filtered on.

Records can be filtered by multiple different fields. If you want to combine filters using boolean logic, nest them under the AND, OR, or NOT keys of a parent filter. Filters can be nested deeply by passing multiple levels boolean condition filters.

You can also pass a list of filters to the filter parameter which will be implicitly ANDed with one another such that they all need to match for a record to be returned.

Available filters
GraphQL
1input ShopifyProductFilter {
2 AND: [ShopifyProductFilter]
3 OR: [ShopifyProductFilter]
4 NOT: [ShopifyProductFilter]
5 id: IDFilter
6 createdAt: DateTimeFilter
7 updatedAt: DateTimeFilter
8 state: StateFilter
9 body: StringFilter
10 handle: StringFilter
11 productType: StringFilter
12 publishedAt: DateTimeFilter
13 publishedScope: StringFilter
14 shopifyCreatedAt: DateTimeFilter
15 tags: AnyFilter
16 shopifyUpdatedAt: DateTimeFilter
17 templateSuffix: StringFilter
18 title: StringFilter
19 vendor: StringFilter
20 shop: IDFilter
21}
Find Shopify Products created in the last day
const yesterday = new Date(Date.now() - 864e5);
const shopifyProductRecords = await api.shopifyProduct.findMany({
filter: { createdAt: { greaterThan: yesterday } },
});
const yesterday = new Date(Date.now() - 864e5);
const [result, refresh] = useFindMany(api.shopifyProduct, {
filter: { createdAt: { greaterThan: yesterday } },
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($filter: [ShopifyProductFilter!]) {
2 shopifyProducts(filter: $filter) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
1{
2 "filter": {
3 "createdAt": {
4 "greaterThan": "2022-10-03T06:42:38.985Z"
5 }
6 }
7}
Shopify Products created this week or updated today
1const yesterday = new Date(Date.now() - 86400000);
2const oneWeekAgo = new Date(Date.now() - 604800000);
3const shopifyProductRecords = await api.shopifyProduct.findMany({
4 filter: {
5 OR: [
6 {
7 createdAt: { greaterThan: oneWeekAgo },
8 },
9 {
10 updated: { greaterThan: yesterday },
11 },
12 ],
13 },
14});
1const yesterday = new Date(Date.now() - 86400000);
2const oneWeekAgo = new Date(Date.now() - 604800000);
3const [result, refresh] = useFindMany(api.shopifyProduct, {
4 filter: {
5 OR: [
6 {
7 createdAt: { greaterThan: oneWeekAgo },
8 },
9 {
10 updated: { greaterThan: yesterday },
11 },
12 ],
13 },
14});
15const { data, error, fetching } = result;
1query FindManyShopifyProducts($filter: [ShopifyProductFilter!]) {
2 shopifyProducts(filter: $filter) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
1{
2 "filter": {
3 "OR": [
4 {
5 "createdAt": {
6 "greaterThan": "2022-09-27T06:42:38.985Z"
7 }
8 },
9 {
10 "updated": {
11 "greaterThan": "2022-10-03T06:42:38.985Z"
12 }
13 }
14 ]
15 }
16}
Filter records that are in the created state
const shopifyProductRecords = await api.shopifyProduct.findMany({
filter: {
state: { inState: "created" },
},
});
1const [result, refresh] = useFindMany(api.shopifyProduct, {
2 filter: {
3 state: { inState: "created" },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifyProducts($filter: [ShopifyProductFilter!]) {
2 shopifyProducts(filter: $filter) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
1{
2 "filter": {
3 "state": {
4 "inState": "created"
5 }
6 }
7}

Most field types in Gadget are filterable, so you are able to filter by fields you have added to a model as well.

const shopifyProductRecords = await api.shopifyProduct.findMany({
filter: {
id: { isSet: true },
},
});
1const [result, refresh] = useFindMany(api.shopifyProduct, {
2 filter: {
3 id: { isSet: true },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifyProducts($filter: [ShopifyProductFilter!]) {
2 shopifyProducts(filter: $filter) {
3 edges {
4 node {
5 __typename
6 id
7 state
8 # ...
9 createdAt
10 updatedAt
11 }
12 }
13 }
14}
Variables
json
1{
2 "filter": {
3 "id": {
4 "isSet": true
5 }
6 }
7}

Pagination

All Gadget record lists, including the top level Shopify Product finder as well as associations to Shopify Product, are structured as GraphQL connections. GraphQL connections are the defacto standard for querying lists and support cursor based forward and backward pagination. When querying via GraphQL, you must select the edges field and then the node field to get the Shopify Product record. When querying using a Gadget API client, the GraphQL queries are generated for you and the records are unwrapped and returned as a GadgetRecordList ready for use.

Shopify Product pagination supports the standard GraphQL connection pagination arguments: first + after, or last + before. Pagination is done using cursors, which you can retrieve from the edge.cursor field or the pageInfo.startCursor properties.

Get the first page of 25 Shopify Products
const shopifyProductRecords = await api.shopifyProduct.findMany({ first: 25 });
console.log(shopifyProductRecords.length); //=> no greater than 25
const [result, refresh] = useFindMany(api.shopifyProduct, { first: 25 });
const { data, error, fetching } = result;
console.log(data?.length); //=> no greater than 25
1query FindManyShopifyProducts($first: Int, $after: String) {
2 shopifyProducts(first: $first, after: $after) {
3 edges {
4 cursor
5 node {
6 __typename
7 id
8 state
9 # ...
10 createdAt
11 updatedAt
12 }
13 }
14 pageInfo {
15 endCursor
16 hasNextPage
17 hasPreviousPage
18 startCursor
19 }
20 }
21}
Variables
json
{
"first": 25
}

The after cursor used in this example data won't return any records if used in a real API request.

Next 25 Shopify Product records after cursor
const shopifyProductRecords = await api.shopifyProduct.findMany({
after: "abcdefg",
first: 25,
});
const [result, refresh] = useFindMany(api.shopifyProduct, {
after: "abcdefg",
first: 25,
});
const { data, error, fetching } = result;
1query FindManyShopifyProducts($first: Int, $after: String) {
2 shopifyProducts(first: $first, after: $after) {
3 edges {
4 cursor
5 node {
6 __typename
7 id
8 state
9 # ...
10 createdAt
11 updatedAt
12 }
13 }
14 pageInfo {
15 endCursor
16 hasNextPage
17 hasPreviousPage
18 startCursor
19 }
20 }
21}
Variables
json
{
"first": 25,
"after": "abcdefg"
}

Pagination Limits

Root level record finders like shopifyProducts support a maximum page size of 250 records, and a default page size of 50 records. The page size is controlled using the first or last GraphQL field arguments.

Related record finders that access lists of records through a HasMany or HasManyThrough field support a maximum page size of 100 records, and a default page size of 50 records.

Get the next or previous page

When using the generated JavaScript API client, the record lists returned from find many calls can be paginated using the nextPage() or previousPage() option.

Both nextPage() and previousPage() will throw an error if the corresponding hasNextPage or hasPreviousPage is false.

JavaScript
1const shopifyProductRecords =
2 await api.shopifyProduct.findMany();
3if (shopifyProductRecords.hasNextPage) {
4 const nextPage =
5 await shopifyProductRecords.nextPage();
6}
7if (
8 shopifyProductRecords.hasPreviousPage
9) {
10 const prevPage =
11 await shopifyProductRecords.previousPage();
12}

Selecting fields, and fields of fields

When using the JavaScript client, all of findOne, maybeFindOne, findMany, findFirst, maybeFindFirst, and various action functions, allow requesting specific fields of a Shopify Product and its relationships. The select option controls which fields are selected in the generated GraphQL query sent to the Gadget API. Pass each field you want to select in an object, with true as the value for scalar fields, and a nested object of the same shape for nested fields.

Gadget has a default selection that will retrieve all of the scalar fields for a Shopify Product, as well as concise representations of each of the relationships containing an id and an automatically inferred title field. If you don't pass a select option to a record finder, this default selection will be used.

Select only some Shopify Product fields
// fetch only the id, state, and createdAt field
const shopifyProductRecords = await api.shopifyProduct.findMany({
select: { id: true, state: true, createdAt: true },
});
// fetch only the id, state, and createdAt field
const [result, refresh] = useFindMany(api.shopifyProduct, {
select: { id: true, state: true, createdAt: true },
});
const { data, error, fetching } = result;
Type Safety

The select option is fully type safe if you're using TypeScript. The returned GadgetRecord type will have a <Shape> exactly matching the fields and nested fields you selected. For more information, see Type Safety .

This behavior of selecting only some fields is built right into GraphQL. If you want to limit or expand what you retrieve from a GraphQL query, include or exclude those fields in your GraphQL query. For more information on executing GraphQL queries, see GraphQL.

Select nested Shopify Product fields
1// fetch the id, state, and createdAt field, and fetch some nested fields from an example relationship field named `someRelatedObject`
2const shopifyProductRecords = await api.shopifyProduct.findMany({
3 select: {
4 id: true,
5 state: true,
6 createdAt: true,
7 someRelatedObject: { id: true, createdAt: true },
8 },
9});
1// fetch the id, state, and createdAt field, and fetch some nested fields from an example relationship field named `someRelatedObject`
2const [result, refresh] = useFindMany(api.shopifyProduct, {
3 select: {
4 id: true,
5 state: true,
6 createdAt: true,
7 someRelatedObject: { id: true, createdAt: true },
8 },
9});
10const { data, error, fetching } = result;

Combining parameters

Sort, search, filtering, selection, and pagination parameters can be combined to access the exact set of records needed for your use case.

Combining Parameters
1const shopifyProductRecords = await api.shopifyProduct.findMany({
2 search: "<some search query>",
3 sort: { createdAt: "Descending" },
4 filter: { updatedAt: { greaterThan: new Date(Date.now() - 864e5) } },
5 select: { id: true, createdAt: true },
6 first: 25,
7 after: "abcdefg",
8});
1const [result, refresh] = useFindMany(api.shopifyProduct, {
2 search: "<some search query>",
3 sort: { createdAt: "Descending" },
4 filter: { updatedAt: { greaterThan: new Date(Date.now() - 864e5) } },
5 select: { id: true, createdAt: true },
6 first: 25,
7 after: "abcdefg",
8});
9const { data, error, fetching } = result;
1query FindManyShopifyProducts(
2 $after: String
3 $before: String
4 $first: Int
5 $last: Int
6 $search: String
7 $sort: [ShopifyProductSort!]
8 $filter: [ShopifyProductFilter!]
9) {
10 shopifyProducts(
11 after: $after
12 before: $before
13 first: $first
14 last: $last
15 search: $search
16 sort: $sort
17 filter: $filter
18 ) {
19 edges {
20 cursor
21 node {
22 __typename
23 id
24 state
25 body
26 createdAt
27 handle
28 images {
29 edges {
30 node {
31 id
32 state
33 createdAt
34 height
35 position
36 product {
37 id
38 state
39 body
40 createdAt
41 handle
42 productType
43 publishedAt
44 publishedScope
45 shopifyCreatedAt
46 shopifyUpdatedAt
47 tags
48 templateSuffix
49 title
50 updatedAt
51 vendor
52 }
53 shop {
54 id
55 state
56 accessToken
57 address1
58 address2
59 checkoutApiSupported
60 city
61 cookieConsentLevel
62 country
63 countryCode
64 countryName
65 countyTaxes
66 createdAt
67 currency
68 customerEmail
69 domain
70 eligibleForCardReaderGiveaway
71 eligibleForPayments
72 email
73 enabledPresentmentCurrencies
74 finances
75 forceSsl
76 googleAppsDomain
77 googleAppsLoginEnabled
78 grantedScopes
79 hasDiscounts
80 hasGiftCards
81 hasStorefront
82 ianaTimezone
83 installedViaApiKey
84 latitude
85 longitude
86 moneyFormat
87 moneyInEmailsFormat
88 moneyWithCurrencyFormat
89 moneyWithCurrencyInEmailsFormat
90 multiLocationEnabled
91 myshopifyDomain
92 name
93 passwordEnabled
94 phone
95 planDisplayName
96 planName
97 preLaunchEnabled
98 primaryLocale
99 province
100 provinceCode
101 registeredWebhooks
102 requiresExtraPaymentsAgreement
103 setupRequired
104 shopOwner
105 shopifyCreatedAt
106 shopifyUpdatedAt
107 source
108 taxShipping
109 taxesIncluded
110 timezone
111 updatedAt
112 weightUnit
113 zipCode
114 }
115 shopifyCreatedAt
116 shopifyUpdatedAt
117 source
118 updatedAt
119 width
120 }
121 }
122 }
123 productType
124 publishedAt
125 publishedScope
126 shop {
127 id
128 state
129 accessToken
130 address1
131 address2
132 checkoutApiSupported
133 city
134 cookieConsentLevel
135 country
136 countryCode
137 countryName
138 countyTaxes
139 createdAt
140 currency
141 customerEmail
142 domain
143 eligibleForCardReaderGiveaway
144 eligibleForPayments
145 email
146 enabledPresentmentCurrencies
147 finances
148 forceSsl
149 googleAppsDomain
150 googleAppsLoginEnabled
151 grantedScopes
152 hasDiscounts
153 hasGiftCards
154 hasStorefront
155 ianaTimezone
156 installedViaApiKey
157 latitude
158 longitude
159 moneyFormat
160 moneyInEmailsFormat
161 moneyWithCurrencyFormat
162 moneyWithCurrencyInEmailsFormat
163 multiLocationEnabled
164 myshopifyDomain
165 name
166 passwordEnabled
167 phone
168 planDisplayName
169 planName
170 preLaunchEnabled
171 primaryLocale
172 province
173 provinceCode
174 registeredWebhooks
175 requiresExtraPaymentsAgreement
176 setupRequired
177 shopOwner
178 shopifyCreatedAt
179 shopifyUpdatedAt
180 source
181 taxShipping
182 taxesIncluded
183 timezone
184 updatedAt
185 weightUnit
186 zipCode
187 }
188 shopifyCreatedAt
189 shopifyUpdatedAt
190 tags
191 templateSuffix
192 title
193 updatedAt
194 variants {
195 edges {
196 node {
197 id
198 state
199 barcode
200 compareAtPrice
201 createdAt
202 fulfillmentService
203 grams
204 inventoryManagement
205 inventoryPolicy
206 inventoryQuantity
207 inventoryQuantityAdjustment
208 oldInventoryQuantity
209 option1
210 option2
211 option3
212 position
213 presentmentPrices
214 price
215 product {
216 id
217 state
218 body
219 createdAt
220 handle
221 productType
222 publishedAt
223 publishedScope
224 shopifyCreatedAt
225 shopifyUpdatedAt
226 tags
227 templateSuffix
228 title
229 updatedAt
230 vendor
231 }
232 productImage {
233 id
234 state
235 createdAt
236 height
237 position
238 shopifyCreatedAt
239 shopifyUpdatedAt
240 source
241 updatedAt
242 width
243 }
244 requiresShipping
245 shop {
246 id
247 state
248 accessToken
249 address1
250 address2
251 checkoutApiSupported
252 city
253 cookieConsentLevel
254 country
255 countryCode
256 countryName
257 countyTaxes
258 createdAt
259 currency
260 customerEmail
261 domain
262 eligibleForCardReaderGiveaway
263 eligibleForPayments
264 email
265 enabledPresentmentCurrencies
266 finances
267 forceSsl
268 googleAppsDomain
269 googleAppsLoginEnabled
270 grantedScopes
271 hasDiscounts
272 hasGiftCards
273 hasStorefront
274 ianaTimezone
275 installedViaApiKey
276 latitude
277 longitude
278 moneyFormat
279 moneyInEmailsFormat
280 moneyWithCurrencyFormat
281 moneyWithCurrencyInEmailsFormat
282 multiLocationEnabled
283 myshopifyDomain
284 name
285 passwordEnabled
286 phone
287 planDisplayName
288 planName
289 preLaunchEnabled
290 primaryLocale
291 province
292 provinceCode
293 registeredWebhooks
294 requiresExtraPaymentsAgreement
295 setupRequired
296 shopOwner
297 shopifyCreatedAt
298 shopifyUpdatedAt
299 source
300 taxShipping
301 taxesIncluded
302 timezone
303 updatedAt
304 weightUnit
305 zipCode
306 }
307 shopifyCreatedAt
308 shopifyUpdatedAt
309 sku
310 taxCode
311 taxable
312 title
313 updatedAt
314 weight
315 weightUnit
316 }
317 }
318 }
319 vendor
320 }
321 }
322 pageInfo {
323 endCursor
324 hasNextPage
325 hasPreviousPage
326 startCursor
327 }
328 }
329}
Variables
json
1{
2 "search": "<some search query>",
3 "sort": {
4 "createdAt": "Descending"
5 },
6 "filter": {
7 "updatedAt": {
8 "greaterThan": "2022-10-03T06:42:39.115Z"
9 }
10 },
11 "first": 25,
12 "after": "abcdefg"
13}

Invoking Actions

Shopify Product records are changed by invoking Actions. Actions are the things that "do" stuff -- update records, make API calls, call backend code, etc. Actions each have one corresponding GraphQL mutation and a corresponding function available in the API client libraries. Nested Actions can also be invoked with the API client, by providing the actions as input to any relationship fields.

Action Result format

Each API action returns results in the same format that includes a success indicator, errors, and the actual result if the action succeeded. The result is the record that was acted on for a model action, or a list of records for a bulk action, or a JSON blob for Global Actions. Model actions that delete the record don't return the record.

The success field returns a boolean indicating if the action executed as expected. Any execution errors are returned in the errors object, which will always be null if success is true or contain ExecutionError objects if success is false.

ExecutionError objects always have a message describing what error prevented the action from succeeding, as well as a code attribute that gives a stable, searchable, human readable error class code for referencing this specific error. Details on each error code can be found in the Errors documentation. All ExecutionError object types returned by the GraphQL object can be one of many types of error, where some types have extra data that is useful for remedying the error. All error types will always have message and code properties, but some, like InvalidRecordError have extra fields for use by clients.

Errors when using the generated client

The generated JavaScript client automatically interprets errors from invoking actions and throws JavaScript Error instances if the action didn't succeed. The Error objects it throws are rich, and expose extra error properties beyond just message and code if they exist.

Errors thrown by the JavaScript client are easiest to catch by using a try/catch statement around an await, like so:

JavaScript
1import {
2 GadgetOperationError,
3 InvalidRecordError,
4} from "@gadget-client/example-app";
5
6// must be in an async function to use `await` syntax
7const runAction = async () => {
8 try {
9 return await api.exampleModel.create(
10 {
11 exampleModel: {
12 name: "example record name",
13 },
14 }
15 );
16 } catch (error) {
17 if (
18 error instanceof
19 GadgetOperationError
20 ) {
21 // a recognized general error has occurred, retry the operation or inspect error.code`
22 console.error(error);
23 } else if (
24 error instanceof
25 InvalidRecordError
26 ) {
27 // the submitted input data for the action was invalid, inspect the invalid fields which `InvalidRecordError` exposes
28 console.error(
29 error.validationErrors
30 );
31 } else {
32 // an unrecognized error occurred, like an HTTP connection interrupted error or a syntax error. Re-throw it because it's not clear what to do to fix ti
33 throw error;
34 }
35 }
36};

For more information on error codes, consult the Errors documentation.

Shopify Product Create

The Create action transitions a Shopify Product from Start to Created.

Input

Create accepts the following input parameters:

Create Input Data
1export interface CreateShopifyProductInput {
2 id?: (Scalars["GadgetID"] | null) | null;
3
4 body?: (Scalars["String"] | null) | null;
5
6 handle?: (Scalars["String"] | null) | null;
7
8 images?: (ShopifyProductImageHasManyInput | null)[];
9
10 productType?: (Scalars["String"] | null) | null;
11
12 publishedAt?: Date | Scalars["ISO8601DateString"] | null;
13
14 publishedScope?: (Scalars["String"] | null) | null;
15
16 shopifyCreatedAt?: Date | Scalars["ISO8601DateString"] | null;
17
18 tags?: (Scalars["JSON"] | null) | null;
19
20 shopifyUpdatedAt?: Date | Scalars["ISO8601DateString"] | null;
21
22 templateSuffix?: (Scalars["String"] | null) | null;
23
24 title?: (Scalars["String"] | null) | null;
25
26 variants?: (ShopifyProductVariantHasManyInput | null)[];
27
28 vendor?: (Scalars["String"] | null) | null;
29
30 shop?: ShopifyShopBelongsToInput | null;
31}
32
33export interface CreateShopifyProductArguments {
34 shopifyProduct?: CreateShopifyProductInput | null;
35}
1input CreateShopifyProductInput {
2 id: GadgetID
3 body: String
4 handle: String
5 images: [ShopifyProductImageHasManyInput]
6 productType: String
7 publishedAt: DateTime
8 publishedScope: String
9 shopifyCreatedAt: DateTime
10 tags: JSON
11 shopifyUpdatedAt: DateTime
12 templateSuffix: String
13 title: String
14 variants: [ShopifyProductVariantHasManyInput]
15 vendor: String
16 shop: ShopifyShopBelongsToInput
17}
18
19input CreateShopifyProductArguments {
20 shopifyProduct: CreateShopifyProductInput
21}
Example Create Invocation
1const shopifyProductRecord = await api.shopifyProduct.create({
2 shopifyProduct: {
3 // field values for Shopify Product
4 },
5});
6console.log(shopifyProductRecord.id); //=> a string
1const [result, createShopifyProduct] = useAction(api.shopifyProduct.create);
2const { data, error, fetching } = result;
3await createShopifyProduct({
4 shopifyProduct: {
5 // field values for Shopify Product
6 },
7});
8console.log(data?.id); //=> a string
1mutation ($shopifyProduct: CreateShopifyProductInput) {
2 createShopifyProduct(shopifyProduct: $shopifyProduct) {
3 success
4 errors {
5 message
6 ... on InvalidRecordError {
7 validationErrors {
8 apiIdentifier
9 message
10 }
11 record
12 model {
13 apiIdentifier
14 }
15 }
16 }
17 shopifyProduct {
18 __typename
19 id
20 state
21 body
22 createdAt
23 handle
24 images {
25 edges {
26 node {
27 id
28 state
29 createdAt
30 height
31 position
32 product {
33 id
34 state
35 body
36 createdAt
37 handle
38 productType
39 publishedAt
40 publishedScope
41 shopifyCreatedAt
42 shopifyUpdatedAt
43 tags
44 templateSuffix
45 title
46 updatedAt
47 vendor
48 }
49 shop {
50 id
51 state
52 accessToken
53 address1
54 address2
55 checkoutApiSupported
56 city
57 cookieConsentLevel
58 country
59 countryCode
60 countryName
61 countyTaxes
62 createdAt
63 currency
64 customerEmail
65 domain
66 eligibleForCardReaderGiveaway
67 eligibleForPayments
68 email
69 enabledPresentmentCurrencies
70 finances
71 forceSsl
72 googleAppsDomain
73 googleAppsLoginEnabled
74 grantedScopes
75 hasDiscounts
76 hasGiftCards
77 hasStorefront
78 ianaTimezone
79 installedViaApiKey
80 latitude
81 longitude
82 moneyFormat
83 moneyInEmailsFormat
84 moneyWithCurrencyFormat
85 moneyWithCurrencyInEmailsFormat
86 multiLocationEnabled
87 myshopifyDomain
88 name
89 passwordEnabled
90 phone
91 planDisplayName
92 planName
93 preLaunchEnabled
94 primaryLocale
95 province
96 provinceCode
97 registeredWebhooks
98 requiresExtraPaymentsAgreement
99 setupRequired
100 shopOwner
101 shopifyCreatedAt
102 shopifyUpdatedAt
103 source
104 taxShipping
105 taxesIncluded
106 timezone
107 updatedAt
108 weightUnit
109 zipCode
110 }
111 shopifyCreatedAt
112 shopifyUpdatedAt
113 source
114 updatedAt
115 width
116 }
117 }
118 }
119 productType
120 publishedAt
121 publishedScope
122 shop {
123 id
124 state
125 accessToken
126 address1
127 address2
128 checkoutApiSupported
129 city
130 cookieConsentLevel
131 country
132 countryCode
133 countryName
134 countyTaxes
135 createdAt
136 currency
137 customerEmail
138 domain
139 eligibleForCardReaderGiveaway
140 eligibleForPayments
141 email
142 enabledPresentmentCurrencies
143 finances
144 forceSsl
145 googleAppsDomain
146 googleAppsLoginEnabled
147 grantedScopes
148 hasDiscounts
149 hasGiftCards
150 hasStorefront
151 ianaTimezone
152 installedViaApiKey
153 latitude
154 longitude
155 moneyFormat
156 moneyInEmailsFormat
157 moneyWithCurrencyFormat
158 moneyWithCurrencyInEmailsFormat
159 multiLocationEnabled
160 myshopifyDomain
161 name
162 passwordEnabled
163 phone
164 planDisplayName
165 planName
166 preLaunchEnabled
167 primaryLocale
168 province
169 provinceCode
170 registeredWebhooks
171 requiresExtraPaymentsAgreement
172 setupRequired
173 shopOwner
174 shopifyCreatedAt
175 shopifyUpdatedAt
176 source
177 taxShipping
178 taxesIncluded
179 timezone
180 updatedAt
181 weightUnit
182 zipCode
183 }
184 shopifyCreatedAt
185 shopifyUpdatedAt
186 tags
187 templateSuffix
188 title
189 updatedAt
190 variants {
191 edges {
192 node {
193 id
194 state
195 barcode
196 compareAtPrice
197 createdAt
198 fulfillmentService
199 grams
200 inventoryManagement
201 inventoryPolicy
202 inventoryQuantity
203 inventoryQuantityAdjustment
204 oldInventoryQuantity
205 option1
206 option2
207 option3
208 position
209 presentmentPrices
210 price
211 product {
212 id
213 state
214 body
215 createdAt
216 handle
217 productType
218 publishedAt
219 publishedScope
220 shopifyCreatedAt
221 shopifyUpdatedAt
222 tags
223 templateSuffix
224 title
225 updatedAt
226 vendor
227 }
228 productImage {
229 id
230 state
231 createdAt
232 height
233 position
234 shopifyCreatedAt
235 shopifyUpdatedAt
236 source
237 updatedAt
238 width
239 }
240 requiresShipping
241 shop {
242 id
243 state
244 accessToken
245 address1
246 address2
247 checkoutApiSupported
248 city
249 cookieConsentLevel
250 country
251 countryCode
252 countryName
253 countyTaxes
254 createdAt
255 currency
256 customerEmail
257 domain
258 eligibleForCardReaderGiveaway
259 eligibleForPayments
260 email
261 enabledPresentmentCurrencies
262 finances
263 forceSsl
264 googleAppsDomain
265 googleAppsLoginEnabled
266 grantedScopes
267 hasDiscounts
268 hasGiftCards
269 hasStorefront
270 ianaTimezone
271 installedViaApiKey
272 latitude
273 longitude
274 moneyFormat
275 moneyInEmailsFormat
276 moneyWithCurrencyFormat
277 moneyWithCurrencyInEmailsFormat
278 multiLocationEnabled
279 myshopifyDomain
280 name
281 passwordEnabled
282 phone
283 planDisplayName
284 planName
285 preLaunchEnabled
286 primaryLocale
287 province
288 provinceCode
289 registeredWebhooks
290 requiresExtraPaymentsAgreement
291 setupRequired
292 shopOwner
293 shopifyCreatedAt
294 shopifyUpdatedAt
295 source
296 taxShipping
297 taxesIncluded
298 timezone
299 updatedAt
300 weightUnit
301 zipCode
302 }
303 shopifyCreatedAt
304 shopifyUpdatedAt
305 sku
306 taxCode
307 taxable
308 title
309 updatedAt
310 weight
311 weightUnit
312 }
313 }
314 }
315 vendor
316 }
317 }
318}
Variables
json
{
"shopifyProduct": {}
}
Output

Create returns the Shopify Product. In the JS client, the fields returned can be controlled with the select option. In GraphQL, the return format is the action result format, which includes the record if the action was successful. You can include or exclude the fields you need right in the mutation itself.

Create Output Data
type CreateShopifyProductResult {
success: Boolean!
errors: [ExecutionError!]
shopifyProduct: ShopifyProduct
}

Shopify Product Delete

The Delete action destroys the record.

Input

Delete operates on one Shopify Product in particular, identified by the id variable.

Example Delete Invocation
await api.shopifyProduct.delete("some-id");
const [result, deleteShopifyProduct] = useAction(api.shopifyProduct.delete);
const { data, error, fetching } = result;
await deleteShopifyProduct({
id: "some-id",
});
1mutation ($id: GadgetID!) {
2 deleteShopifyProduct(id: $id) {
3 success
4 errors {
5 message
6 ... on InvalidRecordError {
7 validationErrors {
8 apiIdentifier
9 message
10 }
11 record
12 model {
13 apiIdentifier
14 }
15 }
16 }
17 }
18}
Variables
json
{
"id": "some-id"
}
Output

Delete deletes the record, so it returns void in the JS client. In GraphQL it returns only the success and errors from the action result format.

Delete Output Data
type DeleteShopifyProductResult {
success: Boolean!
errors: [ExecutionError!]
}

Shopify Product Update

The Update action transitions a Shopify Product from Created to Created.

Input

Update operates on one Shopify Product in particular, identified by the id variable. Update accepts the following input parameters:

Update Input Data
1export interface UpdateShopifyProductInput {
2 id?: (Scalars["GadgetID"] | null) | null;
3
4 body?: (Scalars["String"] | null) | null;
5
6 handle?: (Scalars["String"] | null) | null;
7
8 images?: (ShopifyProductImageHasManyInput | null)[];
9
10 productType?: (Scalars["String"] | null) | null;
11
12 publishedAt?: Date | Scalars["ISO8601DateString"] | null;
13
14 publishedScope?: (Scalars["String"] | null) | null;
15
16 shopifyCreatedAt?: Date | Scalars["ISO8601DateString"] | null;
17
18 tags?: (Scalars["JSON"] | null) | null;
19
20 shopifyUpdatedAt?: Date | Scalars["ISO8601DateString"] | null;
21
22 templateSuffix?: (Scalars["String"] | null) | null;
23
24 title?: (Scalars["String"] | null) | null;
25
26 variants?: (ShopifyProductVariantHasManyInput | null)[];
27
28 vendor?: (Scalars["String"] | null) | null;
29
30 shop?: ShopifyShopBelongsToInput | null;
31}
32
33export interface UpdateShopifyProductArguments {
34 shopifyProduct?: UpdateShopifyProductInput | null;
35}
1input UpdateShopifyProductInput {
2 id: GadgetID
3 body: String
4 handle: String
5 images: [ShopifyProductImageHasManyInput]
6 productType: String
7 publishedAt: DateTime
8 publishedScope: String
9 shopifyCreatedAt: DateTime
10 tags: JSON
11 shopifyUpdatedAt: DateTime
12 templateSuffix: String
13 title: String
14 variants: [ShopifyProductVariantHasManyInput]
15 vendor: String
16 shop: ShopifyShopBelongsToInput
17}
18
19input UpdateShopifyProductArguments {
20 shopifyProduct: UpdateShopifyProductInput
21}
Example Update Invocation
1const shopifyProductRecord = await api.shopifyProduct.update("some-id", {
2 shopifyProduct: {
3 // field values for Shopify Product
4 },
5});
6console.log(shopifyProductRecord.id); //=> a string
1const [result, updateShopifyProduct] = useAction(api.shopifyProduct.update);
2const { data, error, fetching } = result;
3await updateShopifyProduct({
4 id: "some-id",
5 shopifyProduct: {
6 // field values for Shopify Product
7 },
8});
9console.log(data?.id); //=> a string
1mutation ($id: GadgetID!, $shopifyProduct: UpdateShopifyProductInput) {
2 updateShopifyProduct(id: $id, shopifyProduct: $shopifyProduct) {
3 success
4 errors {
5 message
6 ... on InvalidRecordError {
7 validationErrors {
8 apiIdentifier
9 message
10 }
11 record
12 model {
13 apiIdentifier
14 }
15 }
16 }
17 shopifyProduct {
18 __typename
19 id
20 state
21 body
22 createdAt
23 handle
24 images {
25 edges {
26 node {
27 id
28 state
29 createdAt
30 height
31 position
32