From c70f500acc426ad9272cc4c1eb07fb0e8bb866c8 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 21 Mar 2021 04:34:04 +0100 Subject: [PATCH] Fixed stashed check breaking on empty stashes in PostGraphile plugins. --- src/web/plugins/actors.js | 4 ++-- src/web/plugins/releases.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/web/plugins/actors.js b/src/web/plugins/actors.js index e2e616b4..171aa463 100644 --- a/src/web/plugins/actors.js +++ b/src/web/plugins/actors.js @@ -25,14 +25,14 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({ resolvers: { Actor: { isFavorited(parent) { - if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') { + if (!parent['@stashes'] || (parent['@stashes'].length > 0 && typeof parent['@stashes'][0]['@stash'].primary === 'undefined')) { return null; } return parent['@stashes'].some(({ '@stash': stash }) => stash.primary); }, isStashed(parent, args) { - if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') { + if (!parent['@stashes'] || (parent['@stashes'].length > 0 && typeof parent['@stashes'][0]['@stash'].primary === 'undefined')) { return null; } diff --git a/src/web/plugins/releases.js b/src/web/plugins/releases.js index 235074c6..3d4f1550 100644 --- a/src/web/plugins/releases.js +++ b/src/web/plugins/releases.js @@ -12,14 +12,14 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({ resolvers: { Release: { isFavorited(parent) { - if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') { + if (!parent['@stashes'] || (parent['@stashes'].length > 0 && typeof parent['@stashes'][0]['@stash'].primary === 'undefined')) { return null; } return parent['@stashes'].some(({ '@stash': stash }) => stash.primary); }, isStashed(parent, args) { - if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') { + if (!parent['@stashes'] || (parent['@stashes'].length > 0 && typeof parent['@stashes'][0]['@stash'].primary === 'undefined')) { return null; }