To Create an Empty cart for a logged-in customer by GraphQl in Magento, you need to use Mutation to generate a cart id.
The Response of the createEmptyCart GraphQl mutation used for the add item to the customer cart by passing cart Id in addProductsToCart Mutation.
Payload:
mutation {createEmptyCart}
Header:
Authorization: Bearer <CUSTOMER_TOKEN>
Response:
{
"data": {
"createEmptyCart": "GuvgCYLvz1HWi8ODkzMQ7NodOtlnfCkG"
}
}
String GuvgCYLvz1HWi8ODkzMQ7NodOtlnfCkG used as cart_id while adding product to cart using GraphQl.