PHPackages                             yireo/magento2-sync-graph-ql-session-with-frontend - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yireo/magento2-sync-graph-ql-session-with-frontend

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

yireo/magento2-sync-graph-ql-session-with-frontend
==================================================

Magento 2 module to sync a GraphQL session with the regular session

0.0.2(5y ago)10331[1 PRs](https://github.com/yireo/Yireo_SyncGraphQlSessionWithFrontend/pulls)OSL-3.0PHP

Since Apr 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yireo/Yireo_SyncGraphQlSessionWithFrontend)[ Packagist](https://packagist.org/packages/yireo/magento2-sync-graph-ql-session-with-frontend)[ Docs](https://github.com/yireo/Yireo_SyncGraphQlSessionWithFrontend)[ RSS](/packages/yireo-magento2-sync-graph-ql-session-with-frontend/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (4)Used By (0)

Yireo SyncGraphQlSessionWithFrontend
====================================

[](#yireo-syncgraphqlsessionwithfrontend)

Magento 2 module to sync from the GraphQL session to the Knockout session and from the Knockout session to the GraphQL session.

Summary
-------

[](#summary)

- The GraphQL cart token (aka `masked_id`) is added to the CustomerDatas section `cart` of the Knockout frontend (`customerData.get('cart')`) which is automatically synced by Knockout to local storage;
- Within local storage, you can fetch the GraphQL token again from `mage-cache-storage.cart.masked_id`, for instance if you are switching from a regular Knockout frontend to a React-based checkout;

Kudos
-----

[](#kudos)

Thanks to Willem Wigman for coming up with the idea for putting the cart token in the section data.

Proof-of-Concept for cart
-------------------------

[](#proof-of-concept-for-cart)

Use a GraphQL client within React to generate a cart token:

```
mutation {
  createEmptyCart
}
```

The result might be something like the following:

```
vGS4ZLj6LkFVrH5CkAPEapLhgfbsoQKF
```

You should now be able to navigate to the Knockout frontend. After making a modification to the cart (adding a new item, changing the quantity or just wiping out local storage), you can then inspect the local storage entry `mage-cache-storage.cart.masked_id`: It should hold the same token as mentioned above.

If you add a product to the cart in the Knockout frontend, the same product should be there in the GraphQL session as well:

```
query cart($cartId: String!) {
  cart(cart_id: $cartId){
    id
    items {
      product {
        sku
      }
    }
  }
}
```

Now, add a product to the cart (in this case with a product SKU `24-MB04`:

```
mutation addToCart($cartId: String!) {
  addSimpleProductsToCart(input: {
    cart_id: $cartId,
    cart_items: [{data: {quantity: 1, sku: "24-MB04"}}]
  }) {
    cart {
      id
      total_quantity
      items {
        id
        prices {
          row_total {
            currency
            value
          }
        }
        product {
          url_key
        }
      }
    }
  }
}
```

Next, head over to the Knockout frontend, wipe out local storage `mage-cache-storage.cart` (or do this in Knockout via `customerData.clear()`) and inspect the cart again.

Proof-of-Concept for customer
-----------------------------

[](#proof-of-concept-for-customer)

Use a GraphQL client within React to generate a customer token:

```
mutation login($email:String!, $password:String!) {
  generateCustomerToken(email:$email, password:$password) {
    token
  }
}
```

Next, login as the same customer in the Knockout frontend. The local storage item `mage-cache-storage.customer.customer_token` now refers to the same GraphQL token.

This probably needs some enhancement, so that you are logged in right away in either frontend, without loosing security.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Total

2

Last Release

2132d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1373981?v=4)[Yireo](/maintainers/yireo)[@yireo](https://github.com/yireo)

---

Top Contributors

[![jissereitsma](https://avatars.githubusercontent.com/u/7670482?v=4)](https://github.com/jissereitsma "jissereitsma (10 commits)")

---

Tags

magento2-modulemagentocomposer-installer

### Embed Badge

![Health badge](/badges/yireo-magento2-sync-graph-ql-session-with-frontend/health.svg)

```
[![Health](https://phpackages.com/badges/yireo-magento2-sync-graph-ql-session-with-frontend/health.svg)](https://phpackages.com/packages/yireo-magento2-sync-graph-ql-session-with-frontend)
```

###  Alternatives

[yireo/magento2-googletagmanager2

Add Google Tag Manager to Magento

167930.4k5](/packages/yireo-magento2-googletagmanager2)[yireo/magento2-webp2

Magento 2 module to add WebP support to the Magento frontend

2091.2M7](/packages/yireo-magento2-webp2)[magento/magento-composer-installer

Composer installer for Magento modules

7523.3M318](/packages/magento-magento-composer-installer)[magento-hackathon/magento-composer-installer

Composer installer for Magento modules

214757.6k374](/packages/magento-hackathon-magento-composer-installer)[yireo/magento2-extensionchecker

Scan the code of a Magento module

96151.6k3](/packages/yireo-magento2-extensionchecker)[opengento/module-gdpr

Gdpr Compliance Module for Magento 2

14481.5k](/packages/opengento-module-gdpr)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
