@shopify/admin-graphql-api-utilities
A set of utilities to use when consuming Shopify’s admin graphql api.
Last updated 22 days ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/admin-graphql-api-utilities 
SYNC missed versions from official npm registry.

@shopify/admin-graphql-api-utilities

Build Status License: MIT npm version npm bundle size (minified + gzip)

A set of utilities to use when consuming Shopify’s admin graphql api.

Installation

$ yarn add @shopify/admin-graphql-api-utilities

API Reference

function parseGid(gid: string): string

Given a Gid string, parse out the id.

Example Usage

import {parseGid} from '@shopify/admin-graphql-api-utilities';

parseGid('gid://shopify/Customer/12345');
// → '12345'

function composeGid(key: string, id: number | string): string

Given a key and id, compose a Gid string.

Example Usage

import {composeGid} from '@shopify/admin-graphql-api-utilities';

composeGid('Customer', 12345);
// → 'gid://shopify/Customer/12345'

composeGid('Customer', '67890');
// → 'gid://shopify/Customer/67890'

function nodesFromEdges(edges)

Given an array of edges, return the nodes.

Example Usage

import {nodesFromEdges} from '@shopify/admin-graphql-api-utilities';

nodesFromEdges([
  {node: {id: '1', title: 'title one'}},
  {node: {id: '2', title: 'title two'}},
]);
// → [{id: '1', title: 'title one'}, {id: '2', title: 'title two'}]

function keyFromEdges(edges, key)

Given an array of edges, return a new array of only the specific key from those nodes.

Example Usage

import {keyFromEdges} from '@shopify/admin-graphql-api-utilities';

keyFromEdges(
  [
    {node: {id: '1', title: 'title one'}},
    {node: {id: '2', title: 'title two'}},
  ],
  'title',
);
// → ['title one', 'title two']

Current Tags

  • 0.0.10                                ...           latest (22 days ago)

9 Versions

  • 0.0.10                                ...           22 days ago
  • 0.0.9                                ...           a month ago
  • 0.0.8                                ...           3 months ago
  • 0.0.7                                ...           8 months ago
  • 0.0.6                                ...           8 months ago
  • 0.0.5                                ...           8 months ago
  • 0.0.4                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Downloads
Today 0
This Week 18
This Month 18
Last Day 9
Last Week 0
Last Month 34
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |