Shopify has updated the GraphQL Product
APIs to increase the support for Variants
and Options
limits. If you have any existing integrations with a Shopify connection built with the universal HTTP or GraphQL connector, you should migrate to the latest GraphQL APIs .
Tip
Find additional Celigo migration resources at Shopify 2024-04 API release: Product REST API deprecation.
This article explains how to find deprecated relative URLs in your existing flows and replace them with new ones. For detailed information on the latest GraphQL product APIs, see Using the latest GraphQL product APIs.
Note
Before you update the flow, ensure to clone the flow as a backup or for reference.
Ensure your Shopify connection is configured with the (2024-10) API version or higher. Otherwise, update the API version in the connection form.
-
Sign in to your Celigo integrator.io account.
-
Navigate to Resources > Connections.
-
Search for an existing Universal HTTP Shopify/GraphQL connection. From the Actions overflow menu, select Used by. A list of all items that use this connection appears.
-
Select your browser’s option to open the export or import in a new tab.
-
Change the Form view from HTTP to GraphQL.
-
Navigate and expand the How would you like the records imported? section (here the example is shown for imports built on a universal GraphQL connection)
-
HTTP method *: Select
POST
. -
Query *: Enter the predefined GraphQL query listed here, based on your requirements. For example, if the endpoint is Creates a new product, add the following :
-
-
Click Save and close.
The following queries can be used to retrieve a product or product variant.
Retrieves a list of products: Add resourcePath as data.products.nodes
.
{"query": "{ products(first: 10) { nodes { id title vendor handle tags status bodyHtml createdAt description productType updatedAt publishedAt templateSuffix variants(first: 10) { edges { node { id title price position taxable barcode sku createdAt displayName updatedAt inventoryPolicy inventoryQuantity presentmentPrices(first: 10) { nodes { price { amount currencyCode } compareAtPrice { amount currencyCode } } } image { id } product { id title } } } } options { id name position values } } }}"}
Retrieves a single product: Add resourcePath as data.product
.
{"query": "{ product(id: \"gid://shopify/Product/{{Provide_your_productID}}\") { id title vendor handle tags status bodyHtml createdAt description productType updatedAt publishedAt templateSuffix variants(first: 10) { edges { node { id title price position taxable barcode sku createdAt displayName updatedAt inventoryPolicy presentmentPrices(first: 10) { nodes { price { amount currencyCode } compareAtPrice { amount currencyCode } } } image { id } product { id title } } } } options { id name position values } }}"}
Retrieves a list of meta fields that belong to a product: Add resourcePath as data.product
.
{"query": "{ product(id: \"gid://shopify/Product/{{provide_your_product_ID}}\") { description metafields(first: 10) { nodes { createdAt description id key namespace ownerType type updatedAt value compareDigest jsonValue } } }}"}
Retrieves a list of product variants: Add resourcePath as data.productVariants.nodes
.
{"query": "{ productVariants(first: 10, query: \"product_id:{{provide_your_product_id}}\") { nodes { createdAt compareAtPrice displayName id inventoryPolicy inventoryQuantity position price sku taxCode storefrontId taxable title updatedAt product { createdAt description id publishedAt status title tags updatedAt } inventoryItem { updatedAt sku id } image { id } presentmentPrices(first: 10) { edges { node { price { amount currencyCode } compareAtPrice { currencyCode } } } } } }}"}
Retrieves a single product variant: Add resourcePath as data.productVariant
.
{"query": "{ productVariant(id: \"gid://shopify/ProductVariant/{{provide_your_productVariant_ID}}\") { id title availableForSale displayName barcode compareAtPrice createdAt inventoryPolicy inventoryQuantity position price sku taxCode taxable title updatedAt product { createdAt description id publishedAt status title tags updatedAt } inventoryItem { updatedAt sku id } image { id } presentmentPrices(first: 10) { edges { node { price { amount currencyCode } compareAtPrice { currencyCode } } } } }}"}
Retrieves a list of meta fields that belong to a product variant: Add resourcePath as data.productVariant
.
{"query": "{ productVariant(id: \"gid://shopify/ProductVariant/{{provide_your_productVariant_id}}\") { metafields(first: 10) { nodes { createdAt compareDigest description id jsonValue key namespace ownerType type updatedAt value } } id createdAt displayName inventoryQuantity price sku title updatedAt }}"}
The following Product queries can be used to create, update, or delete a product or product variant .
ProductSet: Create or update operation (the following query can be used to create or update a product or product variant in a single request).
{ "query": "mutation createEntireProduct($input: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $input) { product { id title description variants(first: 100) { nodes { id sku price compareAtPrice taxable taxCode barcode inventoryItem { id tracked } } } } productSetOperation { id product { id } status userErrors { field message } } userErrors { field message } } }", "variables": {{{jsonSerialize record}}} }
{ "query": "mutation productDelete($input: ProductDeleteInput!) { productDelete(input: $input) { deletedProductId userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
Remove a product variant from the database:
{ "query": "mutation ProductVariantsDelete($productId: ID!, $variantsIds: [ID!]!) { productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) { product { id title } userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
The following Product queries can be used to create, update, or delete a product or product variant.
{ "query": "mutation ProductCreate($input: ProductInput!) { productCreate(input: $input) { product { id description createdAt publishedAt status descriptionPlainSummary isGiftCard productType publicationCount tags title totalInventory totalVariants tracksInventory storefrontId updatedAt vendor variants(first: 10) { edges { node { createdAt displayName id inventoryPolicy price sku storefrontId taxCode title updatedAt presentmentPrices(first: 10) { nodes { price { amount currencyCode } compareAtPrice { currencyCode } } } image { id } } } } } userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
{ "query": "mutation ProductUpdate($input: ProductInput!) { productUpdate(input: $input) { product { id description createdAt publishedAt status descriptionPlainSummary isGiftCard productType publicationCount tags title totalInventory totalVariants tracksInventory storefrontId updatedAt vendor variants(first: 10) { edges { node { createdAt displayName id inventoryQuantity inventoryPolicy price sku storefrontId taxCode title updatedAt presentmentPrices(first: 10) { nodes { price { amount currencyCode } compareAtPrice { currencyCode } } } image { id } } } } } userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
To update a subset of variants, you can use any one of the following bulk variant mutations
Creates a new product variant:
{ "query": "mutation ProductVariantsCreate( $productId: ID! $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkCreate(productId: $productId, variants: $variants) { product { createdAt description id legacyResourceId productType status tags title totalInventory vendor updatedAt } productVariants { createdAt displayName id inventoryItem { unitCost { amount } tracked } inventoryPolicy inventoryQuantity sku price product { id } title } userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
Modify an existing product variant:
{ "query": "mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { productVariants { displayName defaultCursor createdAt id inventoryPolicy inventoryQuantity legacyResourceId price position requiresComponents sellableOnlineQuantity sellingPlanGroupCount sku taxCode title taxable updatedAt } product { createdAt description id legacyResourceId productType status tags title totalInventory vendor updatedAt } userErrors { field message } }}", "variables": {{{jsonSerialize record}}} }
Comments
Please sign in to leave a comment.