Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
When using ProductSet GraphiQL to create a product, the product data returned is null. Could you please help troubleshoot the issue?
GraphiQL is
mutation setProductSync($input: ProductSetInput!) { productSet(synchronous: true, input: $input) { product { id title productType status handle vendor descriptionHtml tags createdAt updatedAt publishedAt templateSuffix onlineStoreUrl media(first: 250, query: "media_type:IMAGE") { nodes { ... on MediaImage { createdAt updatedAt fileStatus id mediaContentType image { height width id url } } } } variants(first: 250) { nodes { availableForSale barcode compareAtPrice createdAt defaultCursor displayName sku id title price image { id url height width } inventoryPolicy inventoryQuantity inventoryItem { id sku measurement { weight { unit value } } } } } options { id name values position } } } }
variables is
{ "input": { "descriptionHtml": "<p>Brand: Rongchang Item No.: 002 Specifications: Adult Glasses structure: Framework Whether polarized: No Lens material: PC Style: Retro Frame material: Plastic resistanceUVGrade: UV400 Style: General Visible light penetration rate: 80(%) OEM: Yes Model: 002 Strength: Strong additional printinglogo: Yes Whether to import: No Lens color: black frame ink lens,black frame suit Whether the source of cross-border export is exclusive: No Processing customization: Yes Lens material: PC suitable for face shape: small face Whether near vision is supported: No : :6</p>\n", "files": [ { "contentType": "IMAGE", "originalSource": "https://s-cf-my.shopeesz.com/file/b975d25c88ca345b7e0b199d31f4d014" } ], "handle": "Sunglasses-Korean-Style-Internet-Popular-Sunglasses-Unisex-Sunglasses-V-Brand-Sunglasses-ing2361", "seo": { "description": "Brand: Rongchang\nItem No.: 002\nSpecifications: Adult\nGlasses structure: Framework\nWhether polarized: No\nLens material: PC\nStyle: Retro\nFrame material: Plastic\nresistanceUVGrade: UV400\nStyle: General\nVisible light penetration rate: 80(%)\nOEM: Yes\nModel: 002\nStrength: Strong\nadditional printinglo61", "title": "Sunglasses Korean Style Internet Popular Sunglasses Unisex Sunglasses6" }, "tags": [ "Sunglasses", "Korean-style", "net red", "Sunglasses", "Men and women", "Same paragraph", "Sunglasses" ], "title": "Sunglasses Korean Style Internet Popular Sunglasses Unisex Sunglasses V Brand Sunglasses ing61", "variants": [ { "inventoryItem": { "requiresShipping": true, "tracked": false }, "inventoryPolicy": "CONTINUE", "optionValues": [ { "name": "Default Title", "optionName": "Title" } ], "price": 1998, "sku": "", "taxable": true } ] } }
response is
{ "data": { "productSet": { "product": null } }, "extensions": { "cost": { "requestedQueryCost": 110, "actualQueryCost": 50, "throttleStatus": { "maximumAvailable": 2000, "currentlyAvailable": 1950, "restoreRate": 100 } } } }
You need to request in your mutation the userErrors to see what errors occurs on your request to GraphQL API, you could do something like these:
mutation createProductWithVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
variants(first: 20) {
nodes {
id
inventoryItem {
id
}
}
}
}
userErrors {
field
message
}
}
}
Also, I guess that your problem is that you are requesting two connections in the same mutation (a connection is when you request nodes in a field). Depending on what you want the GraphQL API to return from the mutation, normally you only need the id of the product and maybe the ids from variants. That payload determines the format of the response from the GraphQL API.
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025