@bss-sbc/shopify-api-fetcher
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -12,3 +12,3 @@ "use strict"; | ||
super(message, options); | ||
this.name = ` GraphqlError`; | ||
this.name = `GraphqlError`; | ||
} | ||
@@ -15,0 +15,0 @@ } |
{ | ||
"name": "@bss-sbc/shopify-api-fetcher", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"engines": { | ||
"node": "^14.15.0 || ^16.0.0" | ||
"node": ">=16.16.0" | ||
}, | ||
@@ -14,0 +14,0 @@ "exports": { |
# Shopify API Fetcher | ||
_From: BSS Group > BSS Commerce > Division Shopify/Blockchain_ | ||
_From: BSS Group > BSS Commerce > Division SBC_ | ||
@@ -15,2 +15,51 @@ [![Node version](https://img.shields.io/node/v/@bss-sbc/shopify-api-fetcher.svg?style=flat)](https://nodejs.org/download/) | ||
## Error Handling | ||
`GraphqlError` | ||
- If Graphql response status is not 2xx, throw GraphqlError | ||
```javascript | ||
new GraphqlError('', { | ||
cause: { | ||
status: shopifyResult.status, | ||
errors: JSON_RESULT.errors, | ||
userErrors: false, | ||
cost: JSON_RESULT.extensions ? JSON_RESULT.extensions.cost : null, | ||
}, | ||
}) | ||
``` | ||
- If throttled but not configured to retry, throw GraphqlError | ||
```javascript | ||
new GraphqlError('', { | ||
cause: { | ||
status: isThrottled ? 'throttled' : shopifyResult.status, | ||
errors: JSON_RESULT.errors, | ||
userErrors: false, | ||
cost: JSON_RESULT.extensions ? JSON_RESULT.extensions.cost : null, | ||
}, | ||
}) | ||
``` | ||
- If there are user errors, throw GraphqlError | ||
```javascript | ||
new GraphqlError('', { | ||
cause: { | ||
status: shopifyResult.status, | ||
errors: false, | ||
userErrors: JSON_RESULT.data[JSON_RESULT_FIRST_KEY].userErrors, | ||
cost: JSON_RESULT.extensions ? JSON_RESULT.extensions.cost : null, | ||
}, | ||
}) | ||
``` | ||
- If uncaught error, throw GraphqlError | ||
```javascript | ||
new GraphqlError('', { cause: shopifyError }) | ||
``` | ||
### Example | ||
@@ -17,0 +66,0 @@ |
27320
111