mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
This commit takes all backend changes for signup and invite feature. I was working on these features and removed the generated mutations for type user along the way.
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import uniqueSlug from './slugify/uniqueSlug'
|
|
|
|
const isUniqueFor = (context, type) => {
|
|
return async slug => {
|
|
const session = context.driver.session()
|
|
const response = await session.run(`MATCH(p:${type} {slug: $slug }) return p.slug`, {
|
|
slug,
|
|
})
|
|
session.close()
|
|
return response.records.length === 0
|
|
}
|
|
}
|
|
|
|
export default {
|
|
Mutation: {
|
|
SignupVerification: async (resolve, root, args, context, info) => {
|
|
args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'User')))
|
|
return resolve(root, args, context, info)
|
|
},
|
|
CreatePost: async (resolve, root, args, context, info) => {
|
|
args.slug = args.slug || (await uniqueSlug(args.title, isUniqueFor(context, 'Post')))
|
|
return resolve(root, args, context, info)
|
|
},
|
|
UpdatePost: async (resolve, root, args, context, info) => {
|
|
args.slug = args.slug || (await uniqueSlug(args.title, isUniqueFor(context, 'Post')))
|
|
return resolve(root, args, context, info)
|
|
},
|
|
CreateOrganization: async (resolve, root, args, context, info) => {
|
|
args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Organization')))
|
|
return resolve(root, args, context, info)
|
|
},
|
|
CreateCategory: async (resolve, root, args, context, info) => {
|
|
args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Category')))
|
|
return resolve(root, args, context, info)
|
|
},
|
|
},
|
|
}
|