Hi everyone,
I’m using the Shopify GraphQL Admin API to create a product with multiple variants using the productCreate mutation. The mutation executes successfully and the product is created, but when I query the returned product.variants(first: 13), it only includes one variant, even though I provided several in the input.
The mutation returns no user errors, and the product gets created, but only the first variant appears in the variants list. I expected all three variants to be returned and visible in the store.
Has anyone encountered this issue? Is this a limitation of the productCreate mutation or am I missing something in the input?
Thanks in advance for any help!
Below is the code I used when requesting it
String query = “”"
mutation CreateProduct($product: ProductCreateInput!, $media: [CreateMediaInput!]) {
productCreate(
product: $product,
media: $media
) {
product {
id
title
handle
status
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
variants(first: 13) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
cursor
node {
id
legacyResourceId
title
displayName
position
price
compareAtPrice
sku
barcode
availableForSale
requiresComponents
taxable
taxCode
inventoryPolicy
inventoryQuantity
sellableOnlineQuantity
createdAt
updatedAt
defaultCursor
storefrontId
selectedOptions {
name
value
optionValue {
id
name
hasVariants
linkedMetafieldValue
swatch {
color
image {
id
alt
createdAt
fileStatus
image {
id
altText
height
width
url
}
fileErrors {
code
details
message
}
}
}
}
}
product {
id
handle
title
}
inventoryItem {
id
legacyResourceId
sku
tracked
requiresShipping
duplicateSkuCount
inventoryHistoryUrl
harmonizedSystemCode
countryCodeOfOrigin
provinceCodeOfOrigin
createdAt
updatedAt
unitCost {
amount
currencyCode
}
countryHarmonizedSystemCodes(first: 5) {
edges {
node {
countryCode
harmonizedSystemCode
}
}
}
inventoryLevels(first: 5) {
edges {
node {
id
updatedAt
canDeactivate
deactivationAlert
}
}
}
}
media(first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
alt
status
mediaContentType
mediaErrors {
code
details
message
}
mediaWarnings {
code
message
}
preview {
status
image {
id
url
altText
width
height
originalSrc
}
}
}
}
nodes {
id
alt
status
mediaContentType
mediaErrors {
code
details
message
}
mediaWarnings {
code
message
}
preview {
status
image {
id
url
altText
width
height
originalSrc
}
}
}
}
metafields(first: 5) {
edges {
cursor
node {
id
jsonValue
key
legacyResourceId
namespace
ownerType
type
updatedAt
value
description
compareDigest
createdAt
definition {
id
name
namespace
key
validationStatus
ownerType
pinnedPosition
metafieldsCount
description
useAsCollectionCondition
validations {
name
type
value
}
}
}
}
nodes {
id
jsonValue
key
legacyResourceId
namespace
ownerType
type
updatedAt
value
description
compareDigest
createdAt
definition {
id
name
namespace
key
validationStatus
ownerType
pinnedPosition
metafieldsCount
description
useAsCollectionCondition
validations {
name
type
value
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
image {
id
altText
height
width
originalSrc
src
url
}
events(first: 10) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
action
appTitle
attributeToApp
attributeToUser
createdAt
criticalAlert
message
}
}
}
}
}
nodes {
id
legacyResourceId
title
displayName
position
price
compareAtPrice
sku
barcode
availableForSale
requiresComponents
taxable
taxCode
inventoryPolicy
inventoryQuantity
sellableOnlineQuantity
createdAt
updatedAt
defaultCursor
storefrontId
selectedOptions {
name
value
optionValue {
id
name
hasVariants
linkedMetafieldValue
swatch {
color
image {
id
alt
createdAt
fileStatus
image {
id
altText
height
width
url
}
fileErrors {
code
details
message
}
}
}
}
}
product {
id
handle
title
}
inventoryItem {
id
legacyResourceId
sku
tracked
requiresShipping
duplicateSkuCount
inventoryHistoryUrl
harmonizedSystemCode
countryCodeOfOrigin
provinceCodeOfOrigin
createdAt
updatedAt
unitCost {
amount
currencyCode
}
countryHarmonizedSystemCodes(first: 5) {
edges {
node {
countryCode
harmonizedSystemCode
}
}
}
inventoryLevels(first: 5) {
edges {
node {
id
updatedAt
canDeactivate
deactivationAlert
}
}
}
}
media(first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
alt
status
mediaContentType
mediaErrors {
code
details
message
}
mediaWarnings {
code
message
}
preview {
status
image {
id
url
altText
width
height
originalSrc
}
}
}
}
nodes {
id
alt
status
mediaContentType
mediaErrors {
code
details
message
}
mediaWarnings {
code
message
}
preview {
status
image {
id
url
altText
width
height
originalSrc
}
}
}
}
metafields(first: 5) {
edges {
cursor
node {
id
jsonValue
key
legacyResourceId
namespace
ownerType
type
updatedAt
value
description
compareDigest
createdAt
definition {
id
name
namespace
key
validationStatus
ownerType
pinnedPosition
metafieldsCount
description
useAsCollectionCondition
validations {
name
type
value
}
}
}
}
nodes {
id
jsonValue
key
legacyResourceId
namespace
ownerType
type
updatedAt
value
description
compareDigest
createdAt
definition {
id
name
namespace
key
validationStatus
ownerType
pinnedPosition
metafieldsCount
description
useAsCollectionCondition
validations {
name
type
value
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
image {
id
altText
height
width
originalSrc
src
url
}
events(first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
action
appTitle
attributeToApp
attributeToUser
createdAt
criticalAlert
message
}
}
}
}
}
}
userErrors {
field
message
}
}
}
“”";