Skip to content

Instantly share code, notes, and snippets.

@apurbajnu
Created February 21, 2023 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apurbajnu/44c7e46b53dab6df99364f20f0bae549 to your computer and use it in GitHub Desktop.
Save apurbajnu/44c7e46b53dab6df99364f20f0bae549 to your computer and use it in GitHub Desktop.
Shopify Product Import Graphql
mutation {
productCreate(input: {
title: "Demo Product",
descriptionHtml: "This is a demo product description.",
productType: "Demo Product Type",
vendor: "Demo Vendor",
handle: "demo-product",
published: true,
options: [
{ name: "Size", values: ["Small", "Medium", "Large"] },
{ name: "Color", values: ["Red", "Green", "Blue"] }
],
variants: [
{
price: "19.99",
sku: "demo-product-small-red",
barcode: "1234567890",
inventoryQuantities: [
{ locationId: "gid://shopify/Location/1234567890", availableQuantity: 10 }
],
options: [
{ name: "Size", value: "Small" },
{ name: "Color", value: "Red" }
]
},
{
price: "21.99",
sku: "demo-product-medium-green",
barcode: "0987654321",
inventoryQuantities: [
{ locationId: "gid://shopify/Location/1234567890", availableQuantity: 5 }
],
options: [
{ name: "Size", value: "Medium" },
{ name: "Color", value: "Green" }
]
},
{
price: "24.99",
sku: "demo-product-large-blue",
barcode: "2345678901",
inventoryQuantities: [
{ locationId: "gid://shopify/Location/1234567890", availableQuantity: 3 }
],
options: [
{ name: "Size", value: "Large" },
{ name: "Color", value: "Blue" }
]
}
],
images: [
{ src: "https://example.com/demo-product-image-1.jpg" },
{ src: "https://example.com/demo-product-image-2.jpg" }
]
}) {
product {
id
}
userErrors {
field
message
}
}
}
@apurbajnu
Copy link
Author

{
"input": {
"descriptionHtml": "

This is a demo product description.

",
"collectionsToJoin": [
"Demo Collection 1",
"Demo Collection 2"
],
"collectionsToLeave": [
"Demo Collection 3"
],
"customProductType": "Demo Product Type",
"giftCard": true,
"giftCardTemplateSuffix": "Demo Gift Card Template",
"handle": "demo-product-handle",
"id": "123456789",
"images": [
{
"altText": "Demo Image Alt Text",
"id": "987654321",
"src": "https://example.com/demo-image.jpg"
}
],
"metafields": [
{
"description": "Demo Metafield Description",
"id": "111222333",
"key": "demo_metafield_key",
"namespace": "demo_namespace",
"type": "string",
"value": "demo_metafield_value"
}
],
"options": [
"Demo Option 1",
"Demo Option 2"
],
"privateMetafields": [
{
"key": "demo_private_metafield_key",
"namespace": "demo_private_namespace",
"owner": "demo_variant_123",
"valueInput": {
"value": "demo_private_metafield_value",
"valueType": "string"
}
}
],
"productCategory": {
"productTaxonomyNodeId": ""gid://shopify/ProductTaxonomyNode/177""
},
"productType": "Demo Product Type",
"redirectNewHandle": true,
"requiresSellingPlan": true,
"seo": {
"description": "Demo SEO Description",
"title": "Demo SEO Title"
},
"standardizedProductType": {
"productTaxonomyNodeId": "987654321"
},
"status": "ACTIVE",
"tags": [
"Demo Tag 1",
"Demo Tag 2"
],
"templateSuffix": "demo-template",
"title": "Demo Product Title",
"variants": [
{
"barcode": "123456789",
"compareAtPrice": "$20.00",
"harmonizedSystemCode": "1234.56.7890",
"id": "123",
"imageId": "987654321",
"imageSrc": "https://example.com/demo-variant-image.jpg",
"inventoryItem": {
"cost": "$10.00",
"tracked": true
},
"inventoryPolicy": "DENY",
"inventoryQuantities": [
{
"availableQuantity": 10,
"locationId": "987654321"
}
],
"mediaSrc": [
"https://example.com/demo-variant-video.mp4"
],
"metafields": [
{
"description": "Demo Variant Metafield Description",
"id": "333222111",
"key": "demo_variant_metafield_key",
"namespace": "demo_variant_namespace",
"type": "string",
"value": "demo_variant_metafield_value"
}
],
"options": [
"Demo Option 1 Value",
"Demo Option 2 Value"
],
"position": 1,
"price": "$15.00",
"privateMetafields": [
{
"key": "something",
"namespace": "asdf",
"owner": "sdsd",
"valueInput": {
"value": "asdfasd",
"valueType": "STRING"
}
}
],
"productId": "234234",
"requiresShipping": true,
"sku": "#sdfasdf",
"taxCode": "342342",
"taxable": true,
"weight": 1.1,
"weightUnit": "KILOGRAMS"
}
],
"vendor": "dddd"
}
}

@apurbajnu
Copy link
Author

{
"input": {
"id": "gid://shopify/Product/6962531303503",
"descriptionHtml": "

This is a demo product description.

",
"title": "Single Button Longerline Tailored Apricot Causal Blazer",
"handle": "Single-Button-Longerline-Tailored-Apricot-Causal-Blazer",
"giftCard": false,
"handle": "Single-Button-Longerline-Tailored-Apricot-Causal-Blazer",
"productCategory": {
"productTaxonomyNodeId": "gid://shopify/ProductTaxonomyNode/126"
},
"metafields": [
{
"description": "Defination",
"key": "sound",
"namespace": "prop",
"type": "single_line_text_field",
"value": "dishu dishu"
}
],
"productType": "Blazers",

"status": "ACTIVE",
"tags": [
  "Cocobella", "Apparel", "Women", "Single button"
],
"templateSuffix": "apparel",

"options": [
"size"
],
"variants": [
{
"options": ["S"],
"inventoryItem": {
"cost": "40.63",
"tracked": true
},
"inventoryPolicy": "DENY",
"inventoryQuantities": [
{
"availableQuantity": 10,
"locationId": "gid://shopify/Location/32796573775"
}
],
"price": "99.00",
"sku": "CT1003-Z20-13",
"taxable": true,
"weight": 1.1,
"weightUnit": "KILOGRAMS"
},
{
"options": ["M"],
"inventoryItem": {
"cost": "40.63",
"tracked": true
},
"inventoryPolicy": "DENY",
"inventoryQuantities": [
{
"availableQuantity": 50,
"locationId": "gid://shopify/Location/32796573775"
}
],
"price": "99.00",
"sku": "CT1003-Z20-14",
"taxable": true,
"weight": 1.1,
"weightUnit": "KILOGRAMS"
},
{
"options": ["L"],
"inventoryItem": {
"cost": "40.63",
"tracked": true
},
"inventoryPolicy": "DENY",
"inventoryQuantities": [
{
"availableQuantity": 50,
"locationId": "gid://shopify/Location/32796573775"
}
],
"price": "99.00",
"sku": "CT1003-Z20-15",
"taxable": true,
"weight": 1.1,
"weightUnit": "KILOGRAMS"
},
{
"options": ["XL"],
"inventoryItem": {
"cost": "40.63",
"tracked": true
},
"inventoryPolicy": "DENY",
"inventoryQuantities": [
{
"availableQuantity": 50,
"locationId": "gid://shopify/Location/32796573775"
}
],
"price": "99.00",
"sku": "CT1003-Z20-14",
"taxable": true,
"weight": 1.1,
"weightUnit": "KILOGRAMS"
}

],
"vendor": "Cocobella"

}
}

@apurbajnu
Copy link
Author

mutation productUpdate($input: ProductInput!) {
productUpdate(input: $input) {
product {
# Product fields
}
userErrors {
field
message
}
}
}

mutation productCreate($input: ProductInput!) {
productCreate(input: $input) {
product {
# Product fields
}
shop {
# Shop fields
}
userErrors {
field
message
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment