Exposed comment and meta fields in GraphQL API.

This commit is contained in:
DebaucheryLibrarian 2025-04-04 05:36:47 +02:00
parent 538e6ede5b
commit 0dabbc7233
7 changed files with 53 additions and 2 deletions

24
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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');

View File

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

View File

@ -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 {

View File

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

View File

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