Added stash menu to release page, returning stashes from stash API to avoid reloading or local interpolation.
This commit is contained in:
@@ -5,17 +5,29 @@ const { makeExtendSchemaPlugin, gql } = require('graphile-utils');
|
||||
const schemaExtender = makeExtendSchemaPlugin(_build => ({
|
||||
typeDefs: gql`
|
||||
extend type Release {
|
||||
isStashed: Boolean @requires(columns: ["stashesScenesBySceneId"])
|
||||
isFavorited: Boolean @requires(columns: ["stashesScenesBySceneId"])
|
||||
isStashed(includeFavorites: Boolean = false): Boolean @requires(columns: ["stashesScenesBySceneId"])
|
||||
}
|
||||
`,
|
||||
resolvers: {
|
||||
Release: {
|
||||
isStashed(parent) {
|
||||
if (!parent['@stashes']) {
|
||||
isFavorited(parent) {
|
||||
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return parent['@stashes'].length > 0;
|
||||
return parent['@stashes'].some(({ '@stash': stash }) => stash.primary);
|
||||
},
|
||||
isStashed(parent, args) {
|
||||
if (!parent['@stashes'] || typeof parent['@stashes'][0]['@stash'].primary === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.includeFavorites) {
|
||||
return parent['@stashes'].length > 0;
|
||||
}
|
||||
|
||||
return parent['@stashes'].some(({ '@stash': stash }) => !stash.primary);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user