mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-03-01 12:44:37 +00:00
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
/* eslint-disable @typescript-eslint/require-await */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
import trunc from 'trunc-html'
|
|
|
|
import { DESCRIPTION_EXCERPT_HTML_LENGTH } from '@constants/groups'
|
|
|
|
import type { IMiddlewareResolver } from 'graphql-middleware/dist/types'
|
|
|
|
const createGroup: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
const updateGroup: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
if (args.description)
|
|
args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
const createPost: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
args.contentExcerpt = trunc(args.content, 120).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
const updatePost: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
args.contentExcerpt = trunc(args.content, 120).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
const createComment: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
args.contentExcerpt = trunc(args.content, 180).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
const updateComment: IMiddlewareResolver = async (resolve, root, args, context, info) => {
|
|
args.contentExcerpt = trunc(args.content, 180).html
|
|
return resolve(root, args, context, info)
|
|
}
|
|
|
|
export default {
|
|
Mutation: {
|
|
CreateGroup: createGroup,
|
|
UpdateGroup: updateGroup,
|
|
CreatePost: createPost,
|
|
UpdatePost: updatePost,
|
|
CreateComment: createComment,
|
|
UpdateComment: updateComment,
|
|
},
|
|
}
|