Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
i use this mutation to create the cart:
mutation createCart {
cartCreate(
input: {
buyerIdentity: {
email: "example-email@example.com"
customerAccessToken: "f08ec7d6418751178caa565233"
}
lines: [
{ quantity: 2, merchandiseId: "gid://shopify/Product/8318551621920" }
]
}
) {
cart {
buyerIdentity {
email
}
lines(first: 10) {
edges {
node {
quantity
}
}
}
}
}
}
when i use this in shopify graphiql playground get the given below error:
{
"data": {
"cartCreate": null
},
"errors": [
{
"message": "invalid id",
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"cartCreate"
]
}
]
}
it said invalid id but I am not able to find which wrong id I am providing. Please someone help me to solve the error
You provide product ID. So that reason the Invalid ID error shows. You replace the product ID with the product variant ID like below code.
mutation createCart {
cartCreate(
input: {
buyerIdentity: {
email: "example-email@example.com"
customerAccessToken: "f08ec7d6418751178caa565233"
}
lines: [
{ quantity: 2, merchandiseId: "gid://shopify/ProductVariant/47860404748574" }
]
}
) {
cart {
buyerIdentity {
email
}
lines(first: 10) {
edges {
node {
quantity
}
}
}
}
}
}