Shopify Sync

This page documents the Shopify Sync model.

Data Shape

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

Shopify Sync Schema
1export interface ShopifySync {
2 __typename: "ShopifySync";
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 errorMessage: Scalars["String"] | null;
17
18 shop: ShopifyShop;
19
20 shopId: Scalars["GadgetID"];
21
22 errorDetails: Scalars["String"] | null;
23
24 syncKey: Scalars["String"] | null;
25
26 domain: Scalars["String"];
27
28 /** DateTime that this sync was run from */
29 syncSince: Scalars["DateTime"] | null;
30
31 models: Scalars["JSON"] | null;
32
33 /** Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower. */
34 _all: Scalars["JSONObject"];
35}
1type ShopifySync {
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 errorMessage: String
22 shop: ShopifyShop!
23 shopId: GadgetID!
24 errorDetails: String
25 syncKey: String
26 domain: String!
27
28 """
29 DateTime that this sync was run from
30 """
31 syncSince: DateTime
32 models: JSON
33
34 """
35 Get all the fields for this record. Useful for not having to list out all the fields you want to retrieve, but slower.
36 """
37 _all: JSONObject!
38}

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 Sync record will have this same ShopifySync 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 Sync record

Individual Shopify Sync 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 Sync
const shopifySyncRecord = await api.shopifySync.findOne("some-id");
console.log(shopifySyncRecord.id); //=> a string
console.log(shopifySyncRecord.createdAt); //=> a Date object
const [result, refresh] = useFindOne(api.shopifySync, "some-id");
const { data, error, fetching } = result;
console.log(data?.id); //=> a string
console.log(data?.createdAt); //=> a Date object
1query GetOneShopifySync($id: GadgetID!) {
2 shopifySync(id: $id) {
3 __typename
4 id
5 state
6 createdAt
7 domain
8 errorDetails
9 errorMessage
10 models
11 shop {
12 id
13 state
14 accessToken
15 address1
16 address2
17 checkoutApiSupported
18 city
19 cookieConsentLevel
20 country
21 countryCode
22 countryName
23 countyTaxes
24 createdAt
25 currency
26 customerEmail
27 domain
28 eligibleForCardReaderGiveaway
29 eligibleForPayments
30 email
31 enabledPresentmentCurrencies
32 finances
33 forceSsl
34 googleAppsDomain
35 googleAppsLoginEnabled
36 grantedScopes
37 hasDiscounts
38 hasGiftCards
39 hasStorefront
40 ianaTimezone
41 installedViaApiKey
42 latitude
43 longitude
44 moneyFormat
45 moneyInEmailsFormat
46 moneyWithCurrencyFormat
47 moneyWithCurrencyInEmailsFormat
48 multiLocationEnabled
49 myshopifyDomain
50 name
51 passwordEnabled
52 phone
53 planDisplayName
54 planName
55 preLaunchEnabled
56 primaryLocale
57 province
58 provinceCode
59 registeredWebhooks
60 requiresExtraPaymentsAgreement
61 setupRequired
62 shopOwner
63 shopifyCreatedAt
64 shopifyUpdatedAt
65 source
66 taxShipping
67 taxesIncluded
68 timezone
69 updatedAt
70 weightUnit
71 zipCode
72 }
73 syncKey
74 syncSince
75 updatedAt
76 }
77}
Variables
json
{
"id": "some-id"
}

Retrieving the first of many Shopify Sync 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 Sync
const shopifySyncRecord = await api.shopifySync.findFirst();
console.log(shopifySyncRecord.id); //=> a string
console.log(shopifySyncRecord.createdAt); //=> a Date object
const [result, refresh] = useFindFirst(api.shopifySync);
const { data, error, fetching } = result;
console.log(data?.id); //=> a string
console.log(data?.createdAt); //=> a Date object
1query FindManyShopifySyncs(
2 $first: Int
3 $search: String
4 $sort: [ShopifySyncSort!]
5 $filter: [ShopifySyncFilter!]
6) {
7 shopifySyncs(first: $first, search: $search, sort: $sort, filter: $filter) {
8 edges {
9 node {
10 __typename
11 id
12 state
13 createdAt
14 domain
15 errorDetails
16 errorMessage
17 models
18 shop {
19 id
20 state
21 accessToken
22 address1
23 address2
24 checkoutApiSupported
25 city
26 cookieConsentLevel
27 country
28 countryCode
29 countryName
30 countyTaxes
31 createdAt
32 currency
33 customerEmail
34 domain
35 eligibleForCardReaderGiveaway
36 eligibleForPayments
37 email
38 enabledPresentmentCurrencies
39 finances
40 forceSsl
41 googleAppsDomain
42 googleAppsLoginEnabled
43 grantedScopes
44 hasDiscounts
45 hasGiftCards
46 hasStorefront
47 ianaTimezone
48 installedViaApiKey
49 latitude
50 longitude
51 moneyFormat
52 moneyInEmailsFormat
53 moneyWithCurrencyFormat
54 moneyWithCurrencyInEmailsFormat
55 multiLocationEnabled
56 myshopifyDomain
57 name
58 passwordEnabled
59 phone
60 planDisplayName
61 planName
62 preLaunchEnabled
63 primaryLocale
64 province
65 provinceCode
66 registeredWebhooks
67 requiresExtraPaymentsAgreement
68 setupRequired
69 shopOwner
70 shopifyCreatedAt
71 shopifyUpdatedAt
72 source
73 taxShipping
74 taxesIncluded
75 timezone
76 updatedAt
77 weightUnit
78 zipCode
79 }
80 syncKey
81 syncSince
82 updatedAt
83 }
84 }
85 }
86}
Variables
json
{
"first": 1
}

Retrieving many Shopify Sync records

Pages of Shopify Sync 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 shopifySyncs 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 Syncs

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

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

Retrieving a single Shopify Sync record by a uniquely identifiable field

After adding a unique validation to a field, you can retrieve a single record by using the finders generated below. If you would like to edit the fields returned or filtering, see the filtering section.

Retrieving a single Shopify Sync record by ID

Individual Shopify Sync records can be retrieved using the "find many" API endpoint pre-filtered by the field's ID. Throws if stored data is not unique.

Find Shopify Syncs
const shopifySyncRecord = await api.shopifySync.findById("some-value");
console.log(shopifySyncRecord.id); //=> a string
const [result, refresh] = useFindBy(api.shopifySync.findById, "some-value");
const { data, error, fetching } = result;
console.log(data?.id); //=> a string

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 ShopifySyncSort 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 ShopifySyncSort instead of just one.

GraphQL
1input ShopifySyncSort {
2 id: SortOrder
3 createdAt: SortOrder
4 updatedAt: SortOrder
5 state: SortOrder
6 errorMessage: SortOrder
7 errorDetails: SortOrder
8 syncKey: SortOrder
9 domain: SortOrder
10 syncSince: SortOrder
11 models: SortOrder
12}

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

Sort Shopify Sync by most recently created
const shopifySyncRecords = await api.shopifySync.findMany({
sort: { createdAt: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifySync, {
sort: { createdAt: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($sort: [ShopifySyncSort!]) {
2 shopifySyncs(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 Sync by multiple fields
const shopifySyncRecords = await api.shopifySync.findMany({
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const [result, refresh] = useFindMany(api.shopifySync, {
sort: [{ state: "Descending" }, { createdAt: "Ascending" }],
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($sort: [ShopifySyncSort!]) {
2 shopifySyncs(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 Syncs by ID descending
const shopifySyncRecords = await api.shopifySync.findMany({
sort: { id: "Descending" },
});
const [result, refresh] = useFindMany(api.shopifySync, {
sort: { id: "Descending" },
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($sort: [ShopifySyncSort!]) {
2 shopifySyncs(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 Sync 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 Syncs 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 Syncs
const shopifySyncRecords = await api.shopifySync.findMany({
search: "a specific phrase to search for",
});
const [result, refresh] = useFindMany(api.shopifySync, {
search: "a specific phrase to search for",
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($search: String) {
2 shopifySyncs(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 Sync 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 Syncs 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 ShopifySyncFilter 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 ShopifySyncFilter {
2 AND: [ShopifySyncFilter]
3 OR: [ShopifySyncFilter]
4 NOT: [ShopifySyncFilter]
5 id: IDFilter
6 createdAt: DateTimeFilter
7 updatedAt: DateTimeFilter
8 state: StateFilter
9 errorMessage: StringFilter
10 shop: IDFilter
11 errorDetails: StringFilter
12 syncKey: StringFilter
13 domain: StringFilter
14 syncSince: DateTimeFilter
15 models: AnyFilter
16}
Find Shopify Syncs created in the last day
const yesterday = new Date(Date.now() - 864e5);
const shopifySyncRecords = await api.shopifySync.findMany({
filter: { createdAt: { greaterThan: yesterday } },
});
const yesterday = new Date(Date.now() - 864e5);
const [result, refresh] = useFindMany(api.shopifySync, {
filter: { createdAt: { greaterThan: yesterday } },
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($filter: [ShopifySyncFilter!]) {
2 shopifySyncs(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:34:01.734Z"
5 }
6 }
7}
Shopify Syncs created this week or updated today
1const yesterday = new Date(Date.now() - 86400000);
2const oneWeekAgo = new Date(Date.now() - 604800000);
3const shopifySyncRecords = await api.shopifySync.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.shopifySync, {
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 FindManyShopifySyncs($filter: [ShopifySyncFilter!]) {
2 shopifySyncs(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:34:01.734Z"
7 }
8 },
9 {
10 "updated": {
11 "greaterThan": "2022-10-03T07:34:01.734Z"
12 }
13 }
14 ]
15 }
16}
Filter records that are in the running state
const shopifySyncRecords = await api.shopifySync.findMany({
filter: {
state: { inState: "running" },
},
});
1const [result, refresh] = useFindMany(api.shopifySync, {
2 filter: {
3 state: { inState: "running" },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifySyncs($filter: [ShopifySyncFilter!]) {
2 shopifySyncs(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": "running"
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 shopifySyncRecords = await api.shopifySync.findMany({
filter: {
id: { isSet: true },
},
});
1const [result, refresh] = useFindMany(api.shopifySync, {
2 filter: {
3 id: { isSet: true },
4 },
5});
6const { data, error, fetching } = result;
1query FindManyShopifySyncs($filter: [ShopifySyncFilter!]) {
2 shopifySyncs(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 Sync finder as well as associations to Shopify Sync, 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 Sync 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 Sync 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 Syncs
const shopifySyncRecords = await api.shopifySync.findMany({ first: 25 });
console.log(shopifySyncRecords.length); //=> no greater than 25
const [result, refresh] = useFindMany(api.shopifySync, { first: 25 });
const { data, error, fetching } = result;
console.log(data?.length); //=> no greater than 25
1query FindManyShopifySyncs($first: Int, $after: String) {
2 shopifySyncs(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 Sync records after cursor
const shopifySyncRecords = await api.shopifySync.findMany({
after: "abcdefg",
first: 25,
});
const [result, refresh] = useFindMany(api.shopifySync, {
after: "abcdefg",
first: 25,
});
const { data, error, fetching } = result;
1query FindManyShopifySyncs($first: Int, $after: String) {
2 shopifySyncs(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 shopifySyncs 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 shopifySyncRecords =
2 await api.shopifySync.findMany();
3if (shopifySyncRecords.hasNextPage) {
4 const nextPage =
5 await shopifySyncRecords.nextPage();
6}
7if (
8 shopifySyncRecords.hasPreviousPage
9) {
10 const prevPage =
11 await shopifySyncRecords.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 Sync 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 Sync, 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 Sync fields
// fetch only the id, state, and createdAt field
const shopifySyncRecords = await api.shopifySync.findMany({
select: { id: true, state: true, createdAt: true },
});
// fetch only the id, state, and createdAt field
const [result, refresh] = useFindMany(api.shopifySync, {
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 Sync fields
1// fetch the id, state, and createdAt field, and fetch some nested fields from an example relationship field named `someRelatedObject`
2const shopifySyncRecords = await api.shopifySync.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.shopifySync, {
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 shopifySyncRecords = await api.shopifySync.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.shopifySync, {
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 FindManyShopifySyncs(
2 $after: String
3 $before: String
4 $first: Int
5 $last: Int
6 $search: String
7 $sort: [ShopifySyncSort!]
8 $filter: [ShopifySyncFilter!]
9) {
10 shopifySyncs(
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 createdAt
26 domain
27 errorDetails
28 errorMessage
29 models
30 shop {
31 id
32 state
33 accessToken
34 address1
35 address2
36 checkoutApiSupported
37 city
38 cookieConsentLevel
39 country
40 countryCode
41 countryName
42 countyTaxes
43 createdAt
44 currency
45 customerEmail
46 domain
47 eligibleForCardReaderGiveaway
48 eligibleForPayments
49 email
50 enabledPresentmentCurrencies
51 finances
52 forceSsl
53 googleAppsDomain
54 googleAppsLoginEnabled
55 grantedScopes
56 hasDiscounts
57 hasGiftCards
58 hasStorefront
59 ianaTimezone
60 installedViaApiKey
61 latitude
62 longitude
63 moneyFormat
64 moneyInEmailsFormat
65 moneyWithCurrencyFormat
66 moneyWithCurrencyInEmailsFormat
67 multiLocationEnabled
68 myshopifyDomain
69 name
70 passwordEnabled
71 phone
72 planDisplayName
73 planName
74 preLaunchEnabled
75 primaryLocale
76 province
77 provinceCode
78 registeredWebhooks
79 requiresExtraPaymentsAgreement
80 setupRequired
81 shopOwner
82 shopifyCreatedAt
83 shopifyUpdatedAt
84 source
85 taxShipping
86 taxesIncluded
87 timezone
88 updatedAt
89 weightUnit
90 zipCode
91 }
92 syncKey
93 syncSince
94 updatedAt
95 }
96 }
97 pageInfo {
98 endCursor
99 hasNextPage
100 hasPreviousPage
101 startCursor
102 }
103 }
104}
Variables
json
1{
2 "search": "<some search query>",
3 "sort": {
4 "createdAt": "Descending"
5 },
6 "filter": {
7 "updatedAt": {
8 "greaterThan": "2022-10-03T07:34:01.885Z"
9 }
10 },
11 "first": 25,
12 "after": "abcdefg"
13}

Invoking Actions

Shopify Sync 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 Sync Run

The Run action transitions a Shopify Sync from Start to Running.

Input

Run accepts the following input parameters:

Run Input Data
1export interface RunShopifySyncInput {
2 errorMessage?: (Scalars["String"] | null) | null;
3
4 shop?: ShopifyShopBelongsToInput | null;
5
6 errorDetails?: (Scalars["String"] | null) | null;
7
8 syncKey?: (Scalars["String"] | null) | null;
9
10 domain?: (Scalars["String"] | null) | null;
11
12 syncSince?: Date | Scalars["ISO8601DateString"] | null;
13
14 models?: (Scalars["JSON"] | null) | null;
15}
16
17export interface RunShopifySyncArguments {
18 shopifySync?: RunShopifySyncInput | null;
19}
1input RunShopifySyncInput {
2 errorMessage: String
3 shop: ShopifyShopBelongsToInput
4 errorDetails: String
5 syncKey: String
6 domain: String
7 syncSince: DateTime
8 models: JSON
9}
10
11input RunShopifySyncArguments {
12 shopifySync: RunShopifySyncInput
13}
Example Run Invocation
1const shopifySyncRecord = await api.shopifySync.run({
2 shopifySync: {
3 // field values for Shopify Sync
4 },
5});
6console.log(shopifySyncRecord.id); //=> a string
1const [result, runShopifySync] = useAction(api.shopifySync.run);
2const { data, error, fetching } = result;
3await runShopifySync({
4 shopifySync: {
5 // field values for Shopify Sync
6 },
7});
8console.log(data?.id); //=> a string
1mutation ($shopifySync: RunShopifySyncInput) {
2 runShopifySync(shopifySync: $shopifySync) {
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 shopifySync {
18 __typename
19 id
20 state
21 createdAt
22 domain
23 errorDetails
24 errorMessage
25 models
26 shop {
27 id
28 state
29 accessToken
30 address1
31 address2
32 checkoutApiSupported
33 city
34 cookieConsentLevel
35 country
36 countryCode
37 countryName
38 countyTaxes
39 createdAt
40 currency
41 customerEmail
42 domain
43 eligibleForCardReaderGiveaway
44 eligibleForPayments
45 email
46 enabledPresentmentCurrencies
47 finances
48 forceSsl
49 googleAppsDomain
50 googleAppsLoginEnabled
51 grantedScopes
52 hasDiscounts
53 hasGiftCards
54 hasStorefront
55 ianaTimezone
56 installedViaApiKey
57 latitude
58 longitude
59 moneyFormat
60 moneyInEmailsFormat
61 moneyWithCurrencyFormat
62 moneyWithCurrencyInEmailsFormat
63 multiLocationEnabled
64 myshopifyDomain
65 name
66 passwordEnabled
67 phone
68 planDisplayName
69 planName
70 preLaunchEnabled
71 primaryLocale
72 province
73 provinceCode
74 registeredWebhooks
75 requiresExtraPaymentsAgreement
76 setupRequired
77 shopOwner
78 shopifyCreatedAt
79 shopifyUpdatedAt
80 source
81 taxShipping
82 taxesIncluded
83 timezone
84 updatedAt
85 weightUnit
86 zipCode
87 }
88 syncKey
89 syncSince
90 updatedAt
91 }
92 }
93}
Variables
json
{
"shopifySync": {}
}
Output

Run returns the Shopify Sync. 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.

Run Output Data
type RunShopifySyncResult {
success: Boolean!
errors: [ExecutionError!]
shopifySync: ShopifySync
}

Shopify Sync Complete

The Complete action transitions a Shopify Sync from Running to Completed.

Input

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

Complete Input Data
1export interface CompleteShopifySyncInput {
2 errorMessage?: (Scalars["String"] | null) | null;
3
4 shop?: ShopifyShopBelongsToInput | null;
5
6 errorDetails?: (Scalars["String"] | null) | null;
7
8 syncKey?: (Scalars["String"] | null) | null;
9
10 domain?: (Scalars["String"] | null) | null;
11
12 syncSince?: Date | Scalars["ISO8601DateString"] | null;
13
14 models?: (Scalars["JSON"] | null) | null;
15}
16
17export interface CompleteShopifySyncArguments {
18 shopifySync?: CompleteShopifySyncInput | null;
19}
1input CompleteShopifySyncInput {
2 errorMessage: String
3 shop: ShopifyShopBelongsToInput
4 errorDetails: String
5 syncKey: String
6 domain: String
7 syncSince: DateTime
8 models: JSON
9}
10
11input CompleteShopifySyncArguments {
12 shopifySync: CompleteShopifySyncInput
13}
Example Complete Invocation
1const shopifySyncRecord = await api.shopifySync.complete("some-id", {
2 shopifySync: {
3 // field values for Shopify Sync
4 },
5});
6console.log(shopifySyncRecord.id); //=> a string
1const [result, completeShopifySync] = useAction(api.shopifySync.complete);
2const { data, error, fetching } = result;
3await completeShopifySync({
4 id: "some-id",
5 shopifySync: {
6 // field values for Shopify Sync
7 },
8});
9console.log(data?.id); //=> a string
1mutation ($id: GadgetID!, $shopifySync: CompleteShopifySyncInput) {
2 completeShopifySync(id: $id, shopifySync: $shopifySync) {
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 shopifySync {
18 __typename
19 id
20 state
21 createdAt
22 domain
23 errorDetails
24 errorMessage
25 models
26 shop {
27 id
28 state
29 accessToken
30 address1
31 address2
32 checkoutApiSupported
33 city
34 cookieConsentLevel
35 country
36 countryCode
37 countryName
38 countyTaxes
39 createdAt
40 currency
41 customerEmail
42 domain
43 eligibleForCardReaderGiveaway
44 eligibleForPayments
45 email
46 enabledPresentmentCurrencies
47 finances
48 forceSsl
49 googleAppsDomain
50 googleAppsLoginEnabled
51 grantedScopes
52 hasDiscounts
53 hasGiftCards
54 hasStorefront
55 ianaTimezone
56 installedViaApiKey
57 latitude
58 longitude
59 moneyFormat
60 moneyInEmailsFormat
61 moneyWithCurrencyFormat
62 moneyWithCurrencyInEmailsFormat
63 multiLocationEnabled
64 myshopifyDomain
65 name
66 passwordEnabled
67 phone
68 planDisplayName
69 planName
70 preLaunchEnabled
71 primaryLocale
72 province
73 provinceCode
74 registeredWebhooks
75 requiresExtraPaymentsAgreement
76 setupRequired
77 shopOwner
78 shopifyCreatedAt
79 shopifyUpdatedAt
80 source
81 taxShipping
82 taxesIncluded
83 timezone
84 updatedAt
85 weightUnit
86 zipCode
87 }
88 syncKey
89 syncSince
90 updatedAt
91 }
92 }
93}
Variables
json
{
"id": "some-id",
"shopifySync": {}
}
Output

Complete returns the Shopify Sync. 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.

Complete Output Data
type CompleteShopifySyncResult {
success: Boolean!
errors: [ExecutionError!]
shopifySync: ShopifySync
}

Shopify Sync Error

The Error action transitions a Shopify Sync from Running to Errored.

Input

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

Error Input Data
1export interface ErrorShopifySyncInput {
2 errorMessage?: (Scalars["String"] | null) | null;
3
4 shop?: ShopifyShopBelongsToInput | null;
5
6 errorDetails?: (Scalars["String"] | null) | null;
7
8 syncKey?: (Scalars["String"] | null) | null;
9
10 domain?: (Scalars["String"] | null) | null;
11
12 syncSince?: Date | Scalars["ISO8601DateString"] | null;
13
14 models?: (Scalars["JSON"] | null) | null;
15}
16
17export interface ErrorShopifySyncArguments {
18 shopifySync?: ErrorShopifySyncInput | null;
19}
1input ErrorShopifySyncInput {
2 errorMessage: String
3 shop: ShopifyShopBelongsToInput
4 errorDetails: String
5 syncKey: String
6 domain: String
7 syncSince: DateTime
8 models: JSON
9}
10
11input ErrorShopifySyncArguments {
12 shopifySync: ErrorShopifySyncInput
13}
Example Error Invocation
1const shopifySyncRecord = await api.shopifySync.error("some-id", {
2 shopifySync: {
3 // field values for Shopify Sync
4 },
5});
6console.log(shopifySyncRecord.id); //=> a string
1const [result, errorShopifySync] = useAction(api.shopifySync.error);
2const { data, error, fetching } = result;
3await errorShopifySync({
4 id: "some-id",
5 shopifySync: {
6 // field values for Shopify Sync
7 },
8});
9console.log(data?.id); //=> a string
1mutation ($id: GadgetID!, $shopifySync: ErrorShopifySyncInput) {
2 errorShopifySync(id: $id, shopifySync: $shopifySync) {
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 shopifySync {
18 __typename
19 id
20 state
21 createdAt
22 domain
23 errorDetails
24 errorMessage
25 models
26 shop {
27 id
28 state
29 accessToken
30 address1
31 address2
32 checkoutApiSupported
33 city
34 cookieConsentLevel
35 country
36 countryCode
37 countryName
38 countyTaxes
39 createdAt
40 currency
41 customerEmail
42 domain
43 eligibleForCardReaderGiveaway
44 eligibleForPayments
45 email
46 enabledPresentmentCurrencies
47 finances
48 forceSsl
49 googleAppsDomain
50 googleAppsLoginEnabled
51 grantedScopes
52 hasDiscounts
53 hasGiftCards
54 hasStorefront
55 ianaTimezone
56 installedViaApiKey
57 latitude
58 longitude
59 moneyFormat
60 moneyInEmailsFormat
61 moneyWithCurrencyFormat
62 moneyWithCurrencyInEmailsFormat
63 multiLocationEnabled
64 myshopifyDomain
65 name
66 passwordEnabled
67 phone
68 planDisplayName
69 planName
70 preLaunchEnabled
71 primaryLocale
72 province
73 provinceCode
74 registeredWebhooks
75 requiresExtraPaymentsAgreement
76 setupRequired
77 shopOwner
78 shopifyCreatedAt
79 shopifyUpdatedAt
80 source
81 taxShipping
82 taxesIncluded
83 timezone
84 updatedAt
85 weightUnit
86 zipCode
87 }
88 syncKey
89 syncSince
90 updatedAt
91 }
92 }
93}
Variables
json
{
"id": "some-id",
"shopifySync": {}
}
Output

Error returns the Shopify Sync. 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.

Error Output Data
type ErrorShopifySyncResult {
success: Boolean!
errors: [ExecutionError!]
shopifySync: ShopifySync
}

Linking to an Existing Child Record

During a create or update operation, you can link to existing child records simply by nesting the data structure on your operation, using an update object wrapper around the child record's properties.

Existing nested child
1const shopifyShopRecord = await api.shopifyShop.create({
2 shopifyShop: {
3 address1: "address1Value",
4 syncs: {
5 // Updates existing `shopifySync` record
6 // (`id` of record required),
7 // and links it to shopifyShop.
8 update: {
9 id: "123",
10 errorMessage: "syncsErrorMessageValue",
11 },
12 },
13 },
14});
15console.log(shopifyShopRecord.id); //=> a string
1const [result, createShopifyShop] = useAction(api.shopifyShop.create);
2const { data, error, fetching } = result;
3await createShopifyShop({
4 shopifyShop: {
5 address1: "address1Value",
6 syncs: {
7 // Updates existing `shopifySync` record
8 // (`id` of record required),
9 // and links it to shopifyShop.
10 update: {
11 id: "123",
12 errorMessage: "syncsErrorMessageValue",
13 },
14 },
15 },
16});
17console.log(data?.id); //=> a string
1mutation ($shopifyShop: CreateShopifyShopInput) {
2 createShopifyShop(shopifyShop: $shopifyShop) {
3 success
4 errors {
5 message
6 }
7 shopifyShop {
8 id
9 address1
10 syncs {
11 id
12 }
13 }
14 }
15}
Variables
json
1{
2 "address1": "address1Value",
3 "syncs": {
4 "update": {
5 "id": "123",
6 "errorMessage": "syncsErrorMessageValue"
7 }
8 }
9}

Linking to a New Child Record

During a create or update operation, you can create linked child records simply by nesting the data structure on your operation, using a create object wrapper around the child record's properties.

New nested child
1const shopifyShopRecord = await api.shopifyShop.create({
2 shopifyShop: {
3 address1: "address1Value",
4 syncs: {
5 // Creates `shopifySync` record,
6 // linked to shopifyShop.
7 create: {
8 errorMessage: "syncsErrorMessageValue",
9 },
10 },
11 },
12});
13console.log(shopifyShopRecord.id); //=> a string
1const [result, createShopifyShop] = useAction(api.shopifyShop.create);
2const { data, error, fetching } = result;
3await createShopifyShop({
4 shopifyShop: {
5 address1: "address1Value",
6 syncs: {
7 // Creates `shopifySync` record,
8 // linked to shopifyShop.
9 create: {
10 errorMessage: "syncsErrorMessageValue",
11 },
12 },
13 },
14});
15console.log(data?.id); //=> a string
1mutation ($shopifyShop: CreateShopifyShopInput) {
2 createShopifyShop(shopifyShop: $shopifyShop) {
3 success
4 errors {
5 message
6 }
7 shopifyShop {
8 id
9 address1
10 syncs {
11 id
12 }
13 }
14 }
15}
Variables
json
1{
2 "address1": "address1Value",
3 "syncs": {
4 "create": {
5 "errorMessage": "syncsErrorMessageValue"
6 }
7 }
8}

Linking to an Existing Parent Record

When you wish to link to an existing parent record, you must use a _link property in your data, with the id of the parent record that this child record will belong to.

Linked creation
1const shopifySyncRecord = await api.shopifySync.create({
2 shopifySync: {
3 errorMessage: "errorMessageValue",
4 shop: {
5 _link: "123",
6 },
7 },
8});
9console.log(shopifySyncRecord.id); //=> a string
1const [result, createShopifySync] = useAction(api.shopifySync.create);
2const { data, error, fetching } = result;
3await createShopifySync({
4 shopifySync: {
5 errorMessage: "errorMessageValue",
6 shop: {
7 _link: "123",
8 },
9 },
10});
11console.log(data?.id); //=> a string
1mutation ($shopifySync: CreateShopifySyncInput) {
2 createShopifySync(shopifySync: $shopifySync) {
3 success
4 errors {
5 message
6 }
7 shopifySync {
8 id
9 errorMessage
10 shop {
11 id
12 }
13 }
14 }
15}
Variables
json
1{
2 "errorMessage": "errorMessageValue",
3 "shop": {
4 "_link": "123"
5 }
6}

Linking to a New Parent Record

You cannot directly link to a new parent record when creation a child record. However, you can jointly create both parent and child via the Linking to a New Child Record method.

Bulk Actions

Actions that support it can be performed in bulk. Bulk Actions are executed as a single GraphQL mutation and have a corresponding function available in the API client libraries. Bulk Actions are performed on a set of ids. Bulk Actions repeat the same action, with the same options and parameters, across all ids and should not be confused with batching up different actions in the same request.

Bulk Actions will be performed on the entire set. If an action fails on an individual record, the Bulk Action will still occur on the other records in the set. Only the records which completed the action successfully will be returned.