Update cart note with js-buy-sdk

Update cart note with js-buy-sdk

Lumiere
New Member
4 0 0

I am trying to update the cart note using custom GraphQL mutations and js-buy-sdk client

The documentation is poor regarding mutations and what I got it this so far:

 

const cartId = cartInstance.client.graphQLClient.variable('cartId', 'ID!');
const note = cartInstance.client.graphQLClient.variable('note', 'String!');

const noteMutation = cartInstance.client.graphQLClient.mutation('cartNoteUpdateMutation', [ cartId, note ], (root) => {
 root.add('cartNoteUpdate', { args: { cartId, note } }, (cartNoteUpdate) => {
    cartNoteUpdate.add('userErrors', (userErrors) => {
        userErrors.add('message'),
        userErrors.add('field');
     });
  });
})

cartInstance.client.graphQLClient.send(
   noteMutation, 
    {
       cartId: cartInstance.id,
       note: 'Hello World!'
     })
      .then((res) => {
         console.log(res);
       });

 

When i run this i get a GraphQL error response: "invalid id"

 

I am using this mutation from the Storefront API reference - cartNoteUpdate

 

Note that the cartinstance.is in the code above is the checkoutId I get from the client. In the documentation this mutation needs CartId. Is cartId different from checkoutId ? If yes then where do i get the cartId from?

 

 

 

 

 

 

Replies 0 (0)