diff --git a/package-lock.json b/package-lock.json index 89d308d..66eea3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "floating-vue": "^5.2.2", "graphql": "^16.9.0", "graphql-parse-resolve-info": "^4.13.0", + "graphql-scalars": "^1.24.2", "ip-cidr": "^4.0.0", "js-cookie": "^3.0.5", "knex": "^3.1.0", @@ -7226,6 +7227,21 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/graphql-scalars": { + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.24.2.tgz", + "integrity": "sha512-FoZ11yxIauEnH0E5rCUkhDXHVn/A6BBfovJdimRZCQlFCl+h7aVvarKmI15zG4VtQunmCDdqdtNs6ixThy3uAg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, "node_modules/has-bigints": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", @@ -16700,6 +16716,14 @@ } } }, + "graphql-scalars": { + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.24.2.tgz", + "integrity": "sha512-FoZ11yxIauEnH0E5rCUkhDXHVn/A6BBfovJdimRZCQlFCl+h7aVvarKmI15zG4VtQunmCDdqdtNs6ixThy3uAg==", + "requires": { + "tslib": "^2.5.0" + } + }, "has-bigints": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", diff --git a/package.json b/package.json index 6a0e7dc..fbe3e15 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "floating-vue": "^5.2.2", "graphql": "^16.9.0", "graphql-parse-resolve-info": "^4.13.0", + "graphql-scalars": "^1.24.2", "ip-cidr": "^4.0.0", "js-cookie": "^3.0.5", "knex": "^3.1.0", diff --git a/src/alerts.js b/src/alerts.js index 936c9ce..ae1a5b3 100755 --- a/src/alerts.js +++ b/src/alerts.js @@ -46,6 +46,8 @@ function curateAlert(alert, context = {}) { slug: stash.stash_slug, isPrimary: stash.stash_primary, })) || [], + comment: alert.comment, + meta: alert.meta, }; } @@ -152,6 +154,8 @@ export async function createAlert(alert, reqUser) { all_tags: alert.allTags, all_matches: alert.allMatches, from_preset: alert.preset, + comment: alert.comment, + meta: alert.meta, }) .returning('id'); diff --git a/src/stashes.js b/src/stashes.js index 10966de..dcc18da 100755 --- a/src/stashes.js +++ b/src/stashes.js @@ -35,6 +35,8 @@ export function curateStash(stash, assets = {}) { avatar: `/media/avatars/${assets.user.id}_${assets.user.username}.png`, createdAt: assets.user.created_at, } : null, + comment: stash.comment, + meta: stash.meta, }; return curatedStash; @@ -61,6 +63,8 @@ function curateStashEntry(stash, user) { name: stash.name || undefined, slug: slugify(stash.name) || undefined, public: stash.isPublic ?? false, + comment: stash.comment, + meta: stash.meta, }; return curatedStashEntry; diff --git a/src/web/alerts.js b/src/web/alerts.js index b2f39b5..c664939 100755 --- a/src/web/alerts.js +++ b/src/web/alerts.js @@ -35,6 +35,8 @@ export const alertsSchema = ` notify: Boolean = true email: Boolean = false stashes: [Int!] + comment: String + meta: JSON ): Alert removeAlert(id: Int!): Alert @@ -114,6 +116,8 @@ export const alertsSchema = ` entities: [AlertEntity] matches: [AlertMatch] stashes: [AlertStash] + comment: String + meta: JSON } type Notifications { diff --git a/src/web/graphql.js b/src/web/graphql.js index 46c654f..6cd37e7 100644 --- a/src/web/graphql.js +++ b/src/web/graphql.js @@ -7,6 +7,11 @@ import { GraphQLScalarType, } from 'graphql'; +import { + JSONDefinition, + JSONResolver, +} from 'graphql-scalars'; + import { scenesSchema, fetchScenesGraphql, @@ -69,6 +74,8 @@ const schema = buildSchema(` scalar Date + ${JSONDefinition} + ${scenesSchema} ${moviesSchema} ${actorsSchema} @@ -118,6 +125,7 @@ export async function graphqlApi(req, res) { resolvers: { DateTimeScalar, DateScalar, + JSON: JSONResolver, }, rootValue: { // queries diff --git a/src/web/stashes.js b/src/web/stashes.js index 07299e3..4ca3083 100755 --- a/src/web/stashes.js +++ b/src/web/stashes.js @@ -28,12 +28,16 @@ export const stashesSchema = ` createStash( name: String! isPublic: Boolean + comment: String + meta: JSON ): Stash updateStash( stash: String! name: String isPublic: Boolean + comment: String + meta: JSON ): Stash removeStash( @@ -78,6 +82,8 @@ export const stashesSchema = ` isPublic: Boolean isPrimary: Boolean createdAt: Date + comment: String + meta: JSON } type Stashed { @@ -98,13 +104,13 @@ export async function fetchUserStashesApi(req, res) { } export async function fetchUserStashesGraphql(query, req) { - const stashes = await fetchUserStashes(query.username || req.userId, req.user); + const stashes = await fetchUserStashes(query.username || req.user.id, req.user); return stashes; } export async function fetchStashGraphql(query, req) { - const stashes = await fetchStashByUsernameAndSlug(query.username || req.userId, query.stash, req.user); + const stashes = await fetchStashByUsernameAndSlug(query.username || req.user.id, query.stash, req.user); return stashes; }