GraphQL/Transforms

GraphQL/Transforms

Source:

Utility functions for use by GraphQL resolvers

Methods

(static) assocInternalId(namespace, item)

Assoc an internal ID onto an object by decoding its existing opaque _id Assumes key is _id but key could be provided as another curried param.

Source:
Parameters:
Name Type Description
namespace String

The namespace

item Object

An object with _id property

(static) assocOpaqueId(namespace, item)

Assoc an opaque ID onto an object by transforming its existing _id Assumes key is _id but key could be provided as another curried param.

Source:
Parameters:
Name Type Description
namespace String

The namespace

item Object

An object with _id property

(static) decodeOpaqueId(opaqueId) → {String}

Transforms an opaque ID to an internal ID

Source:
Parameters:
Name Type Description
opaqueId String

The ID to transform

Returns:

An internal ID

Type
String

(static) decodeOpaqueIdForNamespace(namespace, opaqueId) → {String}

Transforms an opaque ID to an internal ID, throwing an error if the namespace is wrong

Source:
Parameters:
Name Type Description
namespace String

The namespace that you expect the decoded ID to have

opaqueId String

The ID to transform

Returns:

An internal ID

Type
String

(static) encodeOpaqueId(namespace, id) → {String}

Transforms an internal ID to an opaque ID

Source:
Parameters:
Name Type Description
namespace String

The namespace of the ID

id String

The ID to transform

Returns:

An opaque ID

Type
String

(static) getXformedCurrenciesByShop(shop) → {Object}

Source:
Parameters:
Name Type Description
shop Object

A shop object

Returns:

A potentially-empty array of currency objects for this shop

Type
Object

(static) getXformedCurrencyByCode(code) → {Object}

Get an individual transformed currency

Source:
Parameters:
Name Type Description
code String

The code that must match the currency.code

Returns:

A Currency object

Type
Object

(static) xformArrayToConnection(connectionArgs, results) → {Object}

Source:
Parameters:
Name Type Description
connectionArgs Object

GraphQL connection arguments

results Array | Promise.<Array>

The array of results

Returns:

A connection shaped object of the results array

Type
Object

(static) xformCurrencyExchangePricing(pricing, currencyCode, context) → {Object}

Converts price to the supplied currency and adds currencyExchangePricing to result

Source:
Parameters:
Name Type Description
pricing Object

Original pricing object

currencyCode String

Code of currency to convert prices to

context Object

Object containing per-request state

Returns:

New pricing object with converted prices

Type
Object

(static) xformProductMedia(mediaItem, context) → {Object}

Source:
Parameters:
Name Type Description
mediaItem Object

object from a catalog product

context Object

an object containing the per-request state

Returns:

transformed product media item

Type
Object