How to get Wishlist GraphQL Query Magento 2?

Magento Wishlist supports the GraphQL query feature. You can refer to the module-wishlist-graph-ql from the Magento core code to get more info on the specific query feature.

The schema.graphql file for the Wishlist module will be available at the path, vendor/magento/module-wishlist-graph-ql/etc/schema.graphqls

You must have enabled the Wishlist feature to get the output of the query by Stores -> Configuration -> Customers -> Wish List -> General Options -> Enable -> Yes.

If you have a disabled wishlist from the configuration and try to execute a wishlist query, it will throw an Error message, The wishlist configuration is currently disabled.

If wishlist settings enable and want to try to execute a query, you will get an expected output,

Syntax:

type Customer {
    wishlist: Wishlist!
}

Steps to Execute Wishlist Query by GraphQL Altair App,

  1. Generate Customer Tokenand set it with Bearer value,
    Authorization Bearer {CUSTOMER_TOKEN}
  2. Wishlist GraphQL Query,
    {
      customer {
        wishlist {
          items_count
          sharing_code
          updated_at
          items {
            id
            qty
            description
            added_at
            product {
              sku
              name
              ... on BundleProduct {
                sku
                dynamic_sku
              }
              ... on ConfigurableProduct {
                sku
                configurable_options {
                  id
                  attribute_id_v2
                  attribute_code
                  label
                  __typename
                  use_default
                  values {
                    store_label
                    swatch_data {
                      value
                    }
                    use_default_value
                  }
                }
              }
            }
          }
        }
      }
    }

A Wishlist is the part of Customer Query from Magento 2.4.

Earlier you can use query wishlist {} but The wishlist query has been deprecated from the 2.4 Version.

Always use the best standard with taking parent as customer{} query and define your wishlist inside it.

As per the above query, we have to use the latest query feature without the deprecated method.

Output:
I have added one simple and one configurable item to the wishlist,

{
  "data": {
    "customer": {
      "wishlist": {
        "items_count": 2,
        "sharing_code": "9xDTH0sApItwqk84eOs1w931jD2RWc4H",
        "updated_at": "2020-10-19 08:16:27",
        "items": [
          {
            "id": 14,
            "qty": 2,
            "description": null,
            "added_at": "2020-10-27 13:24:59",
            "product": {
              "sku": "24-MB04",
              "name": "Strive Shoulder Pack"
            }
          },
          {
            "id": 16,
            "qty": 1,
            "description": null,
            "added_at": "2020-10-27 13:27:37",
            "product": {
              "sku": "MH01",
              "name": "Chaz Kangeroo Hoodie",
              "configurable_options": [
                {
                  "id": 3,
                  "attribute_id_v2": 93,
                  "attribute_code": "color",
                  "label": "Color",
                  "__typename": "ConfigurableProductOptions",
                  "use_default": false,
                  "values": [
                    {
                      "store_label": "Black",
                      "swatch_data": {
                        "value": "#000000"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "Gray",
                      "swatch_data": {
                        "value": "#8f8f8f"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "Orange",
                      "swatch_data": {
                        "value": "#eb6703"
                      },
                      "use_default_value": true
                    }
                  ]
                },
                {
                  "id": 2,
                  "attribute_id_v2": 186,
                  "attribute_code": "size",
                  "label": "Size",
                  "__typename": "ConfigurableProductOptions",
                  "use_default": false,
                  "values": [
                    {
                      "store_label": "XS",
                      "swatch_data": {
                        "value": "XS"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "S",
                      "swatch_data": {
                        "value": "S"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "M",
                      "swatch_data": {
                        "value": "M"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "L",
                      "swatch_data": {
                        "value": "L"
                      },
                      "use_default_value": true
                    },
                    {
                      "store_label": "XL",
                      "swatch_data": {
                        "value": "XL"
                      },
                      "use_default_value": true
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    }
  }
}

You can use only the required field in your output to improve performance instead of getting all the fields in the payload.

If you want to explore the product full details, use the  ... on ConfigurableProduct {} for the configurable item, ... on BundleProduct {} for the bundle item and ... on DownloadableProduct {} for the downloadable item.