@wearejh/m2-pwa-addresses-gql
v0.77.0
Published
GQL implementation of m2-pwa-addresses — drop-in replacement using dedicated Magento address mutations
Keywords
Readme
@wearejh/m2-pwa-addresses-gql
Drop-in GQL replacement for @wearejh/m2-pwa-addresses.
Overview
Replaces all REST-based epics with dedicated Magento GraphQL address mutations.
| Epic | REST | GQL |
|------|------|-----|
| createAddress | PUT /V1/customers/me (full payload) | createCustomerAddress |
| editAddress | PUT /V1/customers/me (full payload) | updateCustomerAddress |
| deleteAddress | PUT /V1/customers/me (filtered payload) | deleteCustomerAddress |
| fetchCountries | GET /V1/directory/countries | countries query |
Key improvements vs REST
- No client-side merging — the REST package had to fetch the full customer, merge changes client-side, then
PUTthe entire customer object back. The GQL package uses dedicated single-address mutations. - Simpler delete —
deleteCustomerAddress(id: Int!)vs constructing a filtered customer payload. - After each mutation, the full
customerquery is run to keep Redux state in sync — no risk of stale data.
Usage
- import { addressesRegister } from '@wearejh/m2-pwa-addresses';
+ import { addressesRegister } from '@wearejh/m2-pwa-addresses-gql';All Redux actions (Addresses.Create, Addresses.Edit, Addresses.Delete, etc.), the reducer, and hooks remain identical.
GQL queries
lib/queries/createCustomerAddress.graphqllib/queries/updateCustomerAddress.graphqllib/queries/deleteCustomerAddress.graphqllib/queries/getCountries.graphql
