Fixed stashed check breaking on empty stashes in PostGraphile plugins.

This commit is contained in:
DebaucheryLibrarian 2021-03-21 04:34:04 +01:00
parent 76a5ccf3f6
commit c70f500acc
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}