forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34701/productvariants query is missing inventoryitem (gatsbyjs#32450)
* add inventoryItem field and subfields, excluding inventoryLevel * add locations query/processor * remove console log * refactor processor to loop once * fix locations typo
- Loading branch information
1 parent
e1a1396
commit abbb5cd
Showing
7 changed files
with
179 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 21 additions & 6 deletions
27
packages/gatsby-source-shopify/src/processors/product-variants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/gatsby-source-shopify/src/query-builders/locations-query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { BulkQuery } from "./bulk-query" | ||
|
||
export class LocationsQuery extends BulkQuery { | ||
query(date?: Date): string { | ||
const publishedStatus = this.pluginOptions.salesChannel | ||
? encodeURIComponent(`${this.pluginOptions.salesChannel}=visible`) | ||
: `published` | ||
|
||
const filters = [`published_status:${publishedStatus}`] | ||
if (date) { | ||
const isoDate = date.toISOString() | ||
filters.push(`created_at:>='${isoDate}' OR updated_at:>='${isoDate}'`) | ||
} | ||
|
||
const queryString = filters.map(f => `(${f})`).join(` AND `) | ||
|
||
const query = ` | ||
{ | ||
locations(query: "${queryString}") { | ||
edges { | ||
node { | ||
id | ||
activatable | ||
address { | ||
address1 | ||
address2 | ||
city | ||
country | ||
countryCode | ||
formatted | ||
latitude | ||
longitude | ||
phone | ||
province | ||
provinceCode | ||
zip | ||
} | ||
addressVerified | ||
deactivatable | ||
deactivatedAt | ||
deletable | ||
fulfillmentService { | ||
callbackUrl | ||
fulfillmentOrdersOptIn | ||
handle | ||
id | ||
inventoryManagement | ||
productBased | ||
serviceName | ||
shippingMethods { | ||
code | ||
label | ||
} | ||
type | ||
} | ||
fulfillsOnlineOrders | ||
hasActiveInventory | ||
hasUnfulfilledOrders | ||
isActive | ||
legacyResourceId | ||
name | ||
shipsInventory | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
return this.bulkOperationQuery(query) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters