Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/admin-graphql-api-utilities

Package Overview
Dependencies
Maintainers
18
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/admin-graphql-api-utilities

A set of utilities to use when consuming Shopify’s admin GraphQL API

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.1K
decreased by-76.93%
Maintainers
18
Weekly downloads
 
Created
Source

@shopify/admin-graphql-api-utilities

Build Status 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

parseGidType(gid: string): string

Given a Gid string, parse out the type.

Example Usage
import {parseGidType} from '@shopify/admin-graphql-api-utilities';

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

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 parseGidWithParams(gid: string): ParsedGid

Given a Gid string, parse out the id and its params.

Example Usage
import {parseGidWithParams} from '@shopify/admin-graphql-api-utilities';

parseGidWithParams('gid://shopify/Customer/12345?sessionId=123&foo=bar');
// → {
//     id: '12345',
//     params: {sessionId: '123', foo: 'bar'}
//   }

function composeGidFactory(namespace: string): Function

Create a new composeGid with a given namespace instead of the default shopify namespace.

Example Usage
import {composeGidFactory} from '@shopify/admin-graphql-api-utilities';

const composeGid = composeGidFactory('CustomApp');

composeGid('Product', '123');
// → 'gid://CustomApp/Product/123'

function composeGid(key: string, id: number | string, params: Record<string, 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', {foo: 'bar'});
// → 'gid://shopify/Customer/67890?foo=bar'

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']

FAQs

Package last updated on 01 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc