I am creating a custom site for a friend of mine and this is my first time actually diving into GraphQL. I am super lost with how this mutation is working, but whenever it is ran, I get a very vague “invalid ID” error. It doesn’t specify if it is the cartId or the itemId. I have been fighting with this for about 12 hours trying to find something that works but can’t seem to get it. Is there something I am missing, or a better way to go about adding an item to a cart?
The mutation looks like this:
`
mutation AddToCart($cartId: ID!, $itemId: ID!) {
cartLinesAdd(cartId: $cartId, lines: [{ quantity: 1, merchandiseId: $itemId}]) {
cart {
id
lines(first: 100) {
edges {
node {
id
quantity
merchandise {
... on ProductVariant {
id
product {
title
}
}
}
}
}
}
}
}
}
`,
variables: { cartId, itemId },