Skip to content

Commit

Permalink
fix(sync-utils): throw error when shopify fetch fails
Browse files Browse the repository at this point in the history
  • Loading branch information
good-idea committed Jul 20, 2020
1 parent 3ca5fcd commit b29443f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 71 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"packages/*"
],
"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@types/jest": "^26.0.4",
"@types/node": "^14.0.22",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"eslint": "^7.4.0",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@types/jest": "^26.0.5",
"@types/node": "^14.0.23",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
Expand All @@ -33,14 +33,14 @@
"lerna": "^3.22.1",
"markdown-toc": "^1.2.0",
"nodemon": "^2.0.4",
"npm-check-updates": "^7.0.1",
"npm-check-updates": "^7.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.1.1",
"ts-jest": "^26.1.3",
"tsdx": "^0.13.2",
"typescript": "^3.9.6",
"typescript": "^3.9.7",
"typesync": "^0.7.0",
"yalc": "^1.0.0-pre.37"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/sync-utils/src/shopify/fetchItemById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ interface NodeResult {
data?: {
node?: Product | Collection
}
errors?: Array<{
message: string
}>
}

export const createFetchItemById = (
Expand All @@ -63,6 +66,10 @@ export const createFetchItemById = (
if (cached) return cached
const result = await query<NodeResult>(NODE_QUERY, { id })
const item = result?.data?.node
if (result.errors) {
const messages = result.errors.map(({ message }) => message).join(' | ')
throw new Error(messages)
}
if (!item) return null
if (!fetchRelated) return item
if (item.__typename === 'Product') {
Expand Down
2 changes: 0 additions & 2 deletions packages/sync-utils/src/shopify/queryFragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export const collectionFragment = gql`
title
description
descriptionHtml
createdAt
publishedAt
__typename
image {
...ImageFragment
Expand Down
118 changes: 59 additions & 59 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@commitlint/cli@^9.0.1":
"@commitlint/cli@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-9.1.1.tgz#24277e6c1e616191a34a7182a1d3e73369a34f98"
integrity sha512-ye9vUZz8Niv77e5ecBWnA2PnuPF+vYy/3BfSZx8sEaNjozJWUolTk/fuqTsoij3bseZBVObd+cVqZgGk8lfEdw==
Expand All @@ -1269,7 +1269,7 @@
resolve-from "5.0.0"
resolve-global "1.0.0"

"@commitlint/config-conventional@^9.0.1":
"@commitlint/config-conventional@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-9.1.1.tgz#c10e6ff8e56bd462fa33e17522b0f98da97daa39"
integrity sha512-t/bvv8ofjj7V4W99eVDyuACaC7Ch4SYaukglBYt/K1Y9Ixg8mCBuFDMGRMhyZn4upUe1ls8l4SO3rjaVbYIjlg==
Expand Down Expand Up @@ -3553,10 +3553,10 @@
dependencies:
jest-diff "^24.3.0"

"@types/jest@^26.0.4":
version "26.0.4"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.4.tgz#d2e513e85aca16992816f192582b5e67b0b15efb"
integrity sha512-4fQNItvelbNA9+sFgU+fhJo8ZFF+AS4Egk3GWwCW2jFtViukXbnztccafAdLhzE/0EiCogljtQQXP8aQ9J7sFg==
"@types/jest@^26.0.5":
version "26.0.5"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.5.tgz#23a8eecf4764a770ea8d3a0d1ea16b96c822035d"
integrity sha512-heU+7w8snfwfjtcj2H458aTx3m5unIToOJhx75ebHilBiiQ39OIdA18WkG4LP08YKeAoWAGvWg8s+22w/PeJ6w==
dependencies:
jest-diff "^25.2.1"
pretty-format "^25.2.1"
Expand Down Expand Up @@ -3634,7 +3634,7 @@
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*", "@types/node@>= 8", "@types/node@^14.0.22":
"@types/node@*", "@types/node@>= 8", "@types/node@^14.0.23":
version "14.0.23"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.23.tgz#676fa0883450ed9da0bb24156213636290892806"
integrity sha512-Z4U8yDAl5TFkmYsZdFPdjeMa57NOvnaf1tljHzhouaPEp7LCj2JKkejpI1ODviIAQuW4CcQmxkQ77rnLsOOoKw==
Expand Down Expand Up @@ -3770,12 +3770,12 @@
regexpp "^3.0.0"
tsutils "^3.17.1"

"@typescript-eslint/eslint-plugin@^3.6.0":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.6.1.tgz#5ced8fd2087fbb83a76973dea4a0d39d9cb4a642"
integrity sha512-06lfjo76naNeOMDl+mWG9Fh/a0UHKLGhin+mGaIw72FUMbMGBkdi/FEJmgEDzh4eE73KIYzHWvOCYJ0ak7nrJQ==
"@typescript-eslint/eslint-plugin@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.0.tgz#0f91aa3c83d019591719e597fbdb73a59595a263"
integrity sha512-4OEcPON3QIx0ntsuiuFP/TkldmBGXf0uKxPQlGtS/W2F3ndYm8Vgdpj/woPJkzUc65gd3iR+qi3K8SDQP/obFg==
dependencies:
"@typescript-eslint/experimental-utils" "3.6.1"
"@typescript-eslint/experimental-utils" "3.7.0"
debug "^4.1.1"
functional-red-black-tree "^1.0.1"
regexpp "^3.0.0"
Expand All @@ -3792,14 +3792,14 @@
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/experimental-utils@3.6.1":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.6.1.tgz#b5a2738ebbceb3fa90c5b07d50bb1225403c4a54"
integrity sha512-oS+hihzQE5M84ewXrTlVx7eTgc52eu+sVmG7ayLfOhyZmJ8Unvf3osyFQNADHP26yoThFfbxcibbO0d2FjnYhg==
"@typescript-eslint/experimental-utils@3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.0.tgz#0ee21f6c48b2b30c63211da23827725078d5169a"
integrity sha512-xpfXXAfZqhhqs5RPQBfAFrWDHoNxD5+sVB5A46TF58Bq1hRfVROrWHcQHHUM9aCBdy9+cwATcvCbRg8aIRbaHQ==
dependencies:
"@types/json-schema" "^7.0.3"
"@typescript-eslint/types" "3.6.1"
"@typescript-eslint/typescript-estree" "3.6.1"
"@typescript-eslint/types" "3.7.0"
"@typescript-eslint/typescript-estree" "3.7.0"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

Expand All @@ -3813,21 +3813,21 @@
"@typescript-eslint/typescript-estree" "2.34.0"
eslint-visitor-keys "^1.1.0"

"@typescript-eslint/parser@^3.6.0":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.6.1.tgz#216e8adf4ee9c629f77c985476a2ea07fb80e1dc"
integrity sha512-SLihQU8RMe77YJ/jGTqOt0lMq7k3hlPVfp7v/cxMnXA9T0bQYoMDfTsNgHXpwSJM1Iq2aAJ8WqekxUwGv5F67Q==
"@typescript-eslint/parser@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.7.0.tgz#3e9cd9df9ea644536feb6e5acdb8279ecff96ce9"
integrity sha512-2LZauVUt7jAWkcIW7djUc3kyW+fSarNEuM3RF2JdLHR9BfX/nDEnyA4/uWz0wseoWVZbDXDF7iF9Jc342flNqQ==
dependencies:
"@types/eslint-visitor-keys" "^1.0.0"
"@typescript-eslint/experimental-utils" "3.6.1"
"@typescript-eslint/types" "3.6.1"
"@typescript-eslint/typescript-estree" "3.6.1"
"@typescript-eslint/experimental-utils" "3.7.0"
"@typescript-eslint/types" "3.7.0"
"@typescript-eslint/typescript-estree" "3.7.0"
eslint-visitor-keys "^1.1.0"

"@typescript-eslint/types@3.6.1":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.6.1.tgz#87600fe79a1874235d3cc1cf5c7e1a12eea69eee"
integrity sha512-NPxd5yXG63gx57WDTW1rp0cF3XlNuuFFB5G+Kc48zZ+51ZnQn9yjDEsjTPQ+aWM+V+Z0I4kuTFKjKvgcT1F7xQ==
"@typescript-eslint/types@3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.7.0.tgz#09897fab0cb95479c01166b10b2c03c224821077"
integrity sha512-reCaK+hyKkKF+itoylAnLzFeNYAEktB0XVfSQvf0gcVgpz1l49Lt6Vo9x4MVCCxiDydA0iLAjTF/ODH0pbfnpg==

"@typescript-eslint/typescript-estree@2.34.0":
version "2.34.0"
Expand All @@ -3842,24 +3842,24 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/typescript-estree@3.6.1":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.6.1.tgz#a5c91fcc5497cce7922ff86bc37d5e5891dcdefa"
integrity sha512-G4XRe/ZbCZkL1fy09DPN3U0mR6SayIv1zSeBNquRFRk7CnVLgkC2ZPj8llEMJg5Y8dJ3T76SvTGtceytniaztQ==
"@typescript-eslint/typescript-estree@3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.0.tgz#66872e6da120caa4b64e6b4ca5c8702afc74738d"
integrity sha512-xr5oobkYRebejlACGr1TJ0Z/r0a2/HUf0SXqPvlgUMwiMqOCu/J+/Dr9U3T0IxpE5oLFSkqMx1FE/dKaZ8KsOQ==
dependencies:
"@typescript-eslint/types" "3.6.1"
"@typescript-eslint/visitor-keys" "3.6.1"
"@typescript-eslint/types" "3.7.0"
"@typescript-eslint/visitor-keys" "3.7.0"
debug "^4.1.1"
glob "^7.1.6"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/visitor-keys@3.6.1":
version "3.6.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.6.1.tgz#5c57a7772f4dd623cfeacc219303e7d46f963b37"
integrity sha512-qC8Olwz5ZyMTZrh4Wl3K4U6tfms0R/mzU4/5W3XeUZptVraGVmbptJbn6h2Ey6Rb3hOs3zWoAUebZk8t47KGiQ==
"@typescript-eslint/visitor-keys@3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz#ac0417d382a136e4571a0b0dcfe52088cb628177"
integrity sha512-k5PiZdB4vklUpUX4NBncn5RBKty8G3ihTY+hqJsCdMuD0v4jofI5xuqwnVcWxfv6iTm2P/dfEa2wMUnsUY8ODw==
dependencies:
eslint-visitor-keys "^1.1.0"

Expand Down Expand Up @@ -4093,7 +4093,7 @@ acorn@^6.0.1, acorn@^6.4.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==

acorn@^7.1.0, acorn@^7.1.1, acorn@^7.2.0:
acorn@^7.1.0, acorn@^7.1.1, acorn@^7.3.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==
Expand Down Expand Up @@ -7457,14 +7457,14 @@ eslint-utils@^1.4.3:
dependencies:
eslint-visitor-keys "^1.1.0"

eslint-utils@^2.0.0:
eslint-utils@^2.0.0, eslint-utils@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
dependencies:
eslint-visitor-keys "^1.1.0"

eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.2.0:
eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
Expand Down Expand Up @@ -7512,10 +7512,10 @@ eslint@^6.1.0:
text-table "^0.2.0"
v8-compile-cache "^2.0.3"

eslint@^7.4.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.4.0.tgz#4e35a2697e6c1972f9d6ef2b690ad319f80f206f"
integrity sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==
eslint@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.5.0.tgz#9ecbfad62216d223b82ac9ffea7ef3444671d135"
integrity sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.10.0"
Expand All @@ -7525,9 +7525,9 @@ eslint@^7.4.0:
doctrine "^3.0.0"
enquirer "^2.3.5"
eslint-scope "^5.1.0"
eslint-utils "^2.0.0"
eslint-visitor-keys "^1.2.0"
espree "^7.1.0"
eslint-utils "^2.1.0"
eslint-visitor-keys "^1.3.0"
espree "^7.2.0"
esquery "^1.2.0"
esutils "^2.0.2"
file-entry-cache "^5.0.1"
Expand All @@ -7541,7 +7541,7 @@ eslint@^7.4.0:
js-yaml "^3.13.1"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.4.1"
lodash "^4.17.14"
lodash "^4.17.19"
minimatch "^3.0.4"
natural-compare "^1.4.0"
optionator "^0.9.1"
Expand All @@ -7563,14 +7563,14 @@ espree@^6.1.2:
acorn-jsx "^5.2.0"
eslint-visitor-keys "^1.1.0"

espree@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-7.1.0.tgz#a9c7f18a752056735bf1ba14cb1b70adc3a5ce1c"
integrity sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==
espree@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-7.2.0.tgz#1c263d5b513dbad0ac30c4991b93ac354e948d69"
integrity sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==
dependencies:
acorn "^7.2.0"
acorn "^7.3.1"
acorn-jsx "^5.2.0"
eslint-visitor-keys "^1.2.0"
eslint-visitor-keys "^1.3.0"

esprima@^4.0.0, esprima@^4.0.1:
version "4.0.1"
Expand Down Expand Up @@ -12251,7 +12251,7 @@ npm-bundled@^1.0.1, npm-bundled@^1.1.1:
dependencies:
npm-normalize-package-bin "^1.0.1"

npm-check-updates@^7.0.1:
npm-check-updates@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/npm-check-updates/-/npm-check-updates-7.0.2.tgz#b57a1662374dac55610c88677711bdb3ba9aef14"
integrity sha512-MyH17fUCFbYShuIyxZj6yqB6YZ47+AjPCgXQiH1oqNe3vElBoJ0toY7nwy88qJbfXnFqjTFigzs9lsoKSK0iUw==
Expand Down Expand Up @@ -16323,7 +16323,7 @@ ts-jest@^24.0.2:
semver "^5.5"
yargs-parser "10.x"

ts-jest@^26.1.1:
ts-jest@^26.1.3:
version "26.1.3"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.1.3.tgz#aac928a05fdf13e3e6dfbc8caec3847442667894"
integrity sha512-beUTSvuqR9SmKQEylewqJdnXWMVGJRFqSz2M8wKJe7GBMmLZ5zw6XXKSJckbHNMxn+zdB3guN2eOucSw2gBMnw==
Expand Down Expand Up @@ -16546,7 +16546,7 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^3.7.3, typescript@^3.9.6:
typescript@^3.7.3, typescript@^3.9.7:
version "3.9.7"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
Expand Down

0 comments on commit b29443f

Please sign in to comment.