Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

shopify-gid

estrattonbailey1.6kMIT1.0.1

Universal encoder/decoder for ID values returned from the Shopify Storefront GraphQL API.

shopify, gid, storefront, api, graphql, shopify, graphql, shopify, id, id, gid://shopify

readme

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