1.0.1 • Published 6 years ago
shopify-gid v1.0.1
shopify-gid
Universal encoder/decoder for ID values returned from the Shopify Storefront GraphQL API. 400 bytes gzipped.
Install
npm i shopify-gid --save
Usage
import { encode, decode } from 'shopify-gid'
decode(base64hash)
decode('Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEyMzQ1...')
// => { type: 'Product', id: '12345', params: { accessToken: 'abcde123' }, raw: 'Z2lkOi8...' }
encode(type, id, params)
encode('Product', 12345, { accessToken: 'abcde123' })
// => Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEyMzQ1...
License
MIT License © Eric Bailey