Exposed comment and meta fields in GraphQL API.
This commit is contained in:
parent
538e6ede5b
commit
0dabbc7233
|
@ -37,6 +37,7 @@
|
||||||
"floating-vue": "^5.2.2",
|
"floating-vue": "^5.2.2",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
"graphql-parse-resolve-info": "^4.13.0",
|
"graphql-parse-resolve-info": "^4.13.0",
|
||||||
|
"graphql-scalars": "^1.24.2",
|
||||||
"ip-cidr": "^4.0.0",
|
"ip-cidr": "^4.0.0",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
|
@ -7226,6 +7227,21 @@
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"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": {
|
"node_modules/has-bigints": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
|
"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": {
|
"has-bigints": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"floating-vue": "^5.2.2",
|
"floating-vue": "^5.2.2",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
"graphql-parse-resolve-info": "^4.13.0",
|
"graphql-parse-resolve-info": "^4.13.0",
|
||||||
|
"graphql-scalars": "^1.24.2",
|
||||||
"ip-cidr": "^4.0.0",
|
"ip-cidr": "^4.0.0",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
|
|
|
@ -46,6 +46,8 @@ function curateAlert(alert, context = {}) {
|
||||||
slug: stash.stash_slug,
|
slug: stash.stash_slug,
|
||||||
isPrimary: stash.stash_primary,
|
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_tags: alert.allTags,
|
||||||
all_matches: alert.allMatches,
|
all_matches: alert.allMatches,
|
||||||
from_preset: alert.preset,
|
from_preset: alert.preset,
|
||||||
|
comment: alert.comment,
|
||||||
|
meta: alert.meta,
|
||||||
})
|
})
|
||||||
.returning('id');
|
.returning('id');
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ export function curateStash(stash, assets = {}) {
|
||||||
avatar: `/media/avatars/${assets.user.id}_${assets.user.username}.png`,
|
avatar: `/media/avatars/${assets.user.id}_${assets.user.username}.png`,
|
||||||
createdAt: assets.user.created_at,
|
createdAt: assets.user.created_at,
|
||||||
} : null,
|
} : null,
|
||||||
|
comment: stash.comment,
|
||||||
|
meta: stash.meta,
|
||||||
};
|
};
|
||||||
|
|
||||||
return curatedStash;
|
return curatedStash;
|
||||||
|
@ -61,6 +63,8 @@ function curateStashEntry(stash, user) {
|
||||||
name: stash.name || undefined,
|
name: stash.name || undefined,
|
||||||
slug: slugify(stash.name) || undefined,
|
slug: slugify(stash.name) || undefined,
|
||||||
public: stash.isPublic ?? false,
|
public: stash.isPublic ?? false,
|
||||||
|
comment: stash.comment,
|
||||||
|
meta: stash.meta,
|
||||||
};
|
};
|
||||||
|
|
||||||
return curatedStashEntry;
|
return curatedStashEntry;
|
||||||
|
|
|
@ -35,6 +35,8 @@ export const alertsSchema = `
|
||||||
notify: Boolean = true
|
notify: Boolean = true
|
||||||
email: Boolean = false
|
email: Boolean = false
|
||||||
stashes: [Int!]
|
stashes: [Int!]
|
||||||
|
comment: String
|
||||||
|
meta: JSON
|
||||||
): Alert
|
): Alert
|
||||||
|
|
||||||
removeAlert(id: Int!): Alert
|
removeAlert(id: Int!): Alert
|
||||||
|
@ -114,6 +116,8 @@ export const alertsSchema = `
|
||||||
entities: [AlertEntity]
|
entities: [AlertEntity]
|
||||||
matches: [AlertMatch]
|
matches: [AlertMatch]
|
||||||
stashes: [AlertStash]
|
stashes: [AlertStash]
|
||||||
|
comment: String
|
||||||
|
meta: JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
type Notifications {
|
type Notifications {
|
||||||
|
|
|
@ -7,6 +7,11 @@ import {
|
||||||
GraphQLScalarType,
|
GraphQLScalarType,
|
||||||
} from 'graphql';
|
} from 'graphql';
|
||||||
|
|
||||||
|
import {
|
||||||
|
JSONDefinition,
|
||||||
|
JSONResolver,
|
||||||
|
} from 'graphql-scalars';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
scenesSchema,
|
scenesSchema,
|
||||||
fetchScenesGraphql,
|
fetchScenesGraphql,
|
||||||
|
@ -69,6 +74,8 @@ const schema = buildSchema(`
|
||||||
|
|
||||||
scalar Date
|
scalar Date
|
||||||
|
|
||||||
|
${JSONDefinition}
|
||||||
|
|
||||||
${scenesSchema}
|
${scenesSchema}
|
||||||
${moviesSchema}
|
${moviesSchema}
|
||||||
${actorsSchema}
|
${actorsSchema}
|
||||||
|
@ -118,6 +125,7 @@ export async function graphqlApi(req, res) {
|
||||||
resolvers: {
|
resolvers: {
|
||||||
DateTimeScalar,
|
DateTimeScalar,
|
||||||
DateScalar,
|
DateScalar,
|
||||||
|
JSON: JSONResolver,
|
||||||
},
|
},
|
||||||
rootValue: {
|
rootValue: {
|
||||||
// queries
|
// queries
|
||||||
|
|
|
@ -28,12 +28,16 @@ export const stashesSchema = `
|
||||||
createStash(
|
createStash(
|
||||||
name: String!
|
name: String!
|
||||||
isPublic: Boolean
|
isPublic: Boolean
|
||||||
|
comment: String
|
||||||
|
meta: JSON
|
||||||
): Stash
|
): Stash
|
||||||
|
|
||||||
updateStash(
|
updateStash(
|
||||||
stash: String!
|
stash: String!
|
||||||
name: String
|
name: String
|
||||||
isPublic: Boolean
|
isPublic: Boolean
|
||||||
|
comment: String
|
||||||
|
meta: JSON
|
||||||
): Stash
|
): Stash
|
||||||
|
|
||||||
removeStash(
|
removeStash(
|
||||||
|
@ -78,6 +82,8 @@ export const stashesSchema = `
|
||||||
isPublic: Boolean
|
isPublic: Boolean
|
||||||
isPrimary: Boolean
|
isPrimary: Boolean
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
|
comment: String
|
||||||
|
meta: JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stashed {
|
type Stashed {
|
||||||
|
@ -98,13 +104,13 @@ export async function fetchUserStashesApi(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchUserStashesGraphql(query, req) {
|
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;
|
return stashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchStashGraphql(query, req) {
|
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;
|
return stashes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue