Skip to main content

wishlistAddItem

Overview

Create a wishlist entry by passing a CreateWishlistInput. Use sessionId for guests or accountId for logged-in users. The response echoes the wishlist with the products array populated.

  • Type: GraphQL Mutation
  • Endpoint: https://subdomain.com
  • Authentication: Authorization: Bearer <TOKEN> (if using accountId)

Mutation

mutation AddToWishlist($createWishlistInput: CreateWishlistInput!) {
addToWishlist(createWishlistInput: $createWishlistInput) {
success
message
data {
_id
accountId
sessionId
app
products {
_id
title
slug
description
app
tags
status
publishedAt
images { _id fileUrl }
collections {
_id
app
title
slug
description
operation
image { _id fileUrl }
}
seo { title description keywords image canonicalUrl }
pricing { compareAtPrice originalPrice price }
variantsCount
dimensions { height width unit }
weight { weight unit }
variants {
_id
product
options {
_id
option { name }
label
type
sortOrder
createdAt
updatedAt
}
images { _id fileUrl }
pricing { originalPrice price compareAtPrice }
quantity
weight { unit weight }
}
options {
_id
product
valuesCount
values { _id label type sortOrder createdAt updatedAt }
name
createdAt
updatedAt
}
}
createdAt
updatedAt
}
}
}

Variables

{
"createWishlistInput": {
"accountId": "<ACCOUNT_ID>",
"sessionId": "<SESSION_ID>",
"product": {
"id": "<PRODUCT_ID>",
"variantId": "<VARIANT_ID>"
}
}
}

Adjust fields to match your backend schema (some implementations accept productId/variantId directly).

Examples

curl -X POST \
https://subdomain.com\
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation AddToWishlist($createWishlistInput: CreateWishlistInput!) { addToWishlist(createWishlistInput: $createWishlistInput) { success message data { _id accountId sessionId products { _id title slug } } } }",
"variables": {
"createWishlistInput": {
"accountId": "<ACCOUNT_ID>",
"sessionId": "<SESSION_ID>",
"product": { "id": "<PRODUCT_ID>", "variantId": "<VARIANT_ID>" }
}
}
}
EOF

Notes

  • Use sessionId for anonymous wishlists and attach accountId once the user logs in.
  • If the backend supports multiple products per mutation, adapt the payload accordingly.
  • Handle success/message to provide user feedback.