When I create a cart with an initial line item, it works as expected. This successfully creates a cart with the initialized line items.
import { gql } from 'graphql-request';
const CREATE_CART = gql`
mutation CreateCart($merchandiseId: String!) {
cartCreate(
input: { lines: [{merchandiseId: $merchandiseId] }
) {
cart {
id
checkoutUrl
lines(first: 1) {
edges {
node {
id
}
}
}
}
}
}
`;
export default CREATE_CART;
When I subsequently add a line item, it removes the initial line item. The initial line item is not in the mutation response, only the recently added line item.
import { gql } from 'graphql-request';
const ADD_LINE_ITEM = gql`
mutation AddLineItem($cartId: ID!, $merchandiseId: ID!) {
cartLinesAdd(cartId: $cartId, lines: [{ merchandiseId: $merchandiseId }]) {
cart {
checkoutUrl
lines(first: 2) {
edges {
node {
id
attributes {
key
value
}
}
}
}
}
userErrors {
field
message
}
}
}
`;
export default ADD_LINE_ITEM;
If I remove the initial line item from create cart and make two successive calls to addLineItem, it works as expected.
This appears to be a bug in the API.