Shopify Product Variant

This page documents the Shopify Product Variant model.

Data Shape

Gadget's database stores Shopify Product Variant 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 Variant:

Shopify Product Variant Schema
1export interface ShopifyProductVariant {
2 __typename: "ShopifyProductVariant";
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 barcode: Scalars["String"] | null;
17
18 compareAtPrice: Scalars["String"] | null;
19
20 fulfillmentService: Scalars["String"] | null;
21
22 grams: Scalars["Float"] | null;
23
24 inventoryManagement: Scalars["String"] | null;
25
26 inventoryPolicy: Scalars["String"] | null;
27
28 productImage: ShopifyProductImage | null;
29
30 productImageId: Scalars["GadgetID"] | null;
31
32 inventoryQuantity: Scalars["Float"] | null;
33
34 inventoryQuantityAdjustment: Scalars["Float"] | null;
35
36 oldInventoryQuantity: Scalars["Float"] | null;
37
38 option1: Scalars["String"] | null;
39
40 option2: Scalars["String"] | null;
41
42 option3: Scalars["String"] | null;
43
44 position: Scalars["Float"] | null;
45
46 presentmentPrices: Scalars["JSON"] | null;
47
48 price: Scalars["String"] | null;
49
50 requiresShipping: Scalars["Boolean"] | null;
51
52 product: ShopifyProduct | null;
53
54 productId: Scalars["GadgetID"] | null;
55
56 shopifyCreatedAt: Scalars["DateTime"] | null;
57
58 sku: Scalars["String"] | null;
59
60 taxCode: Scalars["String"] | null;
61
62 shopifyUpdatedAt: Scalars["DateTime"] | null;
63
64 taxable: Scalars["Boolean"] | null;
65
66 title: Scalars["String"] | null;
67
68 weight: Scalars["Float"] | null;
69
70 weightUnit: Scalars["String"] | null;
71
72 shop: ShopifyShop | null;
73
74 shopId: Scalars["GadgetID"] | null;
75
76 results: ResultConnection;
77
78 /** Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower. */
79 _all: Scalars["JSONObject"];
80}
1type ShopifyProductVariant {
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 barcode: String
22 compareAtPrice: String
23 fulfillmentService: String
24 grams: Float
25 inventoryManagement: String
26 inventoryPolicy: String
27 productImage: ShopifyProductImage
28 productImageId: GadgetID
29 inventoryQuantity: Float
30 inventoryQuantityAdjustment: Float
31 oldInventoryQuantity: Float
32 option1: String
33 option2: String
34 option3: String
35 position: Float
36 presentmentPrices: JSON
37 price: String
38 requiresShipping: Boolean
39 product: ShopifyProduct
40 productId: GadgetID
41 shopifyCreatedAt: DateTime
42 sku: String
43 taxCode: String
44 shopifyUpdatedAt: DateTime
45 taxable: Boolean
46 title: String
47 weight: Float
48 weightUnit: String
49 shop: ShopifyShop
50 shopId: GadgetID
51 results(
52 """
53 Returns the items in the list that come after the specified cursor.
54 """
55 after: String
56
57 """
58 Returns the first n items from the list.
59 """
60 first: Int
61
62 """
63 Returns the items in the list that come before the specified cursor.
64 """
65 before: String
66
67 """
68 Returns the last n items from the list.
69 """
70 last: Int
71
72 """
73 A list of sort orders to return the results in
74 """
75 sort: [ResultSort!]
76
77 """
78 A list of filters to refine the results by
79 """
80 filter: [ResultFilter!]
81
82 """
83 A free form text search query to find records matching
84 """
85 search: String
86 ): ResultConnection!
87
88 """
89 Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower.
90 """
91 _all: JSONObject!
92}

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 Variant record will have this same ShopifyProductVariant 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 Variant record

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

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

Retrieving many Shopify Product Variant records

Pages of Shopify Product Variant 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 shopifyProductVariants 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 Product Variants

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

Find many Shopify Product Variants
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany();
console.log(shopifyProductVariantRecords.length); //=> a number
console.log(shopifyProductVariantRecords[0].id); //=> a string
const [result, refresh] = useFindMany(api.shopifyProductVariant);
const { data, error, fetching } = result;
console.log(data?.length); //=> a number
console.log(data?.[0].length); //=> a string
1query FindManyShopifyProductVariants {
2 shopifyProductVariants {
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 ShopifyProductVariantSort 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 ShopifyProductVariantSort instead of just one.

GraphQL
1input ShopifyProductVariantSort {
2 id: SortOrder
3 createdAt: SortOrder
4 updatedAt: SortOrder
5 state: SortOrder
6 barcode: SortOrder
7 compareAtPrice: SortOrder
8 fulfillmentService: SortOrder
9 grams: SortOrder
10 inventoryManagement: SortOrder
11 inventoryPolicy: SortOrder
12 inventoryQuantity: SortOrder
13 inventoryQuantityAdjustment: SortOrder
14 oldInventoryQuantity: SortOrder
15 option1: SortOrder
16 option2: SortOrder
17 option3: SortOrder
18 position: SortOrder
19 presentmentPrices: SortOrder
20 price: SortOrder
21 requiresShipping: SortOrder
22 shopifyCreatedAt: SortOrder
23 sku: SortOrder
24 taxCode: SortOrder
25 shopifyUpdatedAt: SortOrder
26 taxable: SortOrder
27 title: SortOrder
28 weight: SortOrder
29 weightUnit: SortOrder
30}

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

Sort Shopify Product Variant by most recently created
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
sort: { createdAt: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
sort: { createdAt: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($sort: [ShopifyProductVariantSort!]) {
2 shopifyProductVariants(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 Variant by multiple fields
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($sort: [ShopifyProductVariantSort!]) {
2 shopifyProductVariants(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 Product Variants by ID descending
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
sort: { id: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
sort: { id: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($sort: [ShopifyProductVariantSort!]) {
2 shopifyProductVariants(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 Variant 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 Product Variants 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 Product Variants
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
search: "a specific phrase to search for",
});
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
search: "a specific phrase to search for",
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($search: String) {
2 shopifyProductVariants(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 Variant 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 Product Variants 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 ShopifyProductVariantFilter 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 ShopifyProductVariantFilter {
2 AND: [ShopifyProductVariantFilter]
3 OR: [ShopifyProductVariantFilter]
4 NOT: [ShopifyProductVariantFilter]
5 id: IDFilter
6 createdAt: DateTimeFilter
7 updatedAt: DateTimeFilter
8 state: StateFilter
9 barcode: StringFilter
10 compareAtPrice: StringFilter
11 fulfillmentService: StringFilter
12 grams: FloatFilter
13 inventoryManagement: StringFilter
14 inventoryPolicy: StringFilter
15 productImage: IDFilter
16 inventoryQuantity: FloatFilter
17 inventoryQuantityAdjustment: FloatFilter
18 oldInventoryQuantity: FloatFilter
19 option1: StringFilter
20 option2: StringFilter
21 option3: StringFilter
22 position: FloatFilter
23 presentmentPrices: AnyFilter
24 price: StringFilter
25 requiresShipping: BooleanFilter
26 product: IDFilter
27 shopifyCreatedAt: DateTimeFilter
28 sku: StringFilter
29 taxCode: StringFilter
30 shopifyUpdatedAt: DateTimeFilter
31 taxable: BooleanFilter
32 title: StringFilter
33 weight: FloatFilter
34 weightUnit: StringFilter
35 shop: IDFilter
36}
Find Shopify Product Variants created in the last day
const yesterday = new Date(Date.now() - 864e5);
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
filter: { createdAt: { greaterThan: yesterday } },
});
const yesterday = new Date(Date.now() - 864e5);
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
filter: { createdAt: { greaterThan: yesterday } },
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($filter: [ShopifyProductVariantFilter!]) {
2 shopifyProductVariants(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-03T07:40:52.498Z"
5 }
6 }
7}
Shopify Product Variants created this week or updated today
1const yesterday = new Date(Date.now() - 86400000);
2const oneWeekAgo = new Date(Date.now() - 604800000);
3const shopifyProductVariantRecords = await api.shopifyProductVariant.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.shopifyProductVariant, {
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 FindManyShopifyProductVariants($filter: [ShopifyProductVariantFilter!]) {
2 shopifyProductVariants(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-27T07:40:52.498Z"
7 }
8 },
9 {
10 "updated": {
11 "greaterThan": "2022-10-03T07:40:52.498Z"
12 }
13 }
14 ]
15 }
16}
Filter records that are in the created state
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
filter: {
state: { inState: "created" },
},
});
1const [result, refresh] = useFindMany(api.shopifyProductVariant, {
2 filter: {
3 state: { inState: "created" },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($filter: [ShopifyProductVariantFilter!]) {
2 shopifyProductVariants(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 shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
filter: {
id: { isSet: true },
},
});
1const [result, refresh] = useFindMany(api.shopifyProductVariant, {
2 filter: {
3 id: { isSet: true },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($filter: [ShopifyProductVariantFilter!]) {
2 shopifyProductVariants(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 Variant finder as well as associations to Shopify Product Variant, 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 Variant 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 Variant 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 Product Variants
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
first: 25,
});
console.log(shopifyProductVariantRecords.length); //=> no greater than 25
const [result, refresh] = useFindMany(api.shopifyProductVariant, { first: 25 });
const { data, error, fetching } = result;
console.log(data?.length); //=> no greater than 25
1query FindManyShopifyProductVariants($first: Int, $after: String) {
2 shopifyProductVariants(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 Variant records after cursor
const shopifyProductVariantRecords = await api.shopifyProductVariant.findMany({
after: "abcdefg",
first: 25,
});
const [result, refresh] = useFindMany(api.shopifyProductVariant, {
after: "abcdefg",
first: 25,
});
const { data, error, fetching } = result;
1query FindManyShopifyProductVariants($first: Int, $after: String) {
2 shopifyProductVariants(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 shopifyProductVariants 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 shopifyProductVariantRecords =
2 await api.shopifyProductVariant.findMany();
3if (
4 shopifyProductVariantRecords.hasNextPage
5) {
6 const nextPage =
7 await shopifyProductVariantRecords.nextPage();
8}
9if (
10 shopifyProductVariantRecords.hasPreviousPage
11) {
12 const prevPage =
13 await shopifyProductVariantRecords.previousPage();
14}

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

Invoking Actions

Shopify Product Variant 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 Variant Create

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

Input

Create accepts the following input parameters:

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

Create returns the Shopify Product Variant. 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 CreateShopifyProductVariantResult {
success: Boolean!
errors: [ExecutionError!]
shopifyProductVariant: ShopifyProductVariant
}

Shopify Product Variant Delete

The Delete action destroys the record.

Input

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

Example Delete Invocation
await api.shopifyProductVariant.delete("some-id");
1const [result, deleteShopifyProductVariant] = useAction(
2 api.shopifyProductVariant.delete
3);
4const { data, error, fetching } = result;
5await deleteShopifyProductVariant({
6 id: "some-id",
7});
1mutation ($id: GadgetID!) {
2 deleteShopifyProductVariant(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 DeleteShopifyProductVariantResult {
success: Boolean