mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
- favor over actually deleting the node so that the comments will appear as anonymous and not lose the context of the conversation - the post will not appear, but for admin it will be accessible - follow @roschaefer `PR` review
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { neo4jgraphql } from 'neo4j-graphql-js'
|
|
import fileUpload from './fileUpload'
|
|
|
|
export default {
|
|
Mutation: {
|
|
UpdateUser: async (object, params, context, resolveInfo) => {
|
|
params = await fileUpload(params, { file: 'avatarUpload', url: 'avatar' })
|
|
return neo4jgraphql(object, params, context, resolveInfo, false)
|
|
},
|
|
CreateUser: async (object, params, context, resolveInfo) => {
|
|
params = await fileUpload(params, { file: 'avatarUpload', url: 'avatar' })
|
|
return neo4jgraphql(object, params, context, resolveInfo, false)
|
|
},
|
|
DeleteUser: async (object, params, context, resolveInfo) => {
|
|
const { resource } = params
|
|
const session = context.driver.session()
|
|
|
|
if (resource && resource.length) {
|
|
await Promise.all(
|
|
resource.map(async node => {
|
|
await session.run(
|
|
`
|
|
MATCH (resource:${node})<-[:WROTE]-(author:User {id: $userId})
|
|
SET resource.deleted = true
|
|
RETURN author`,
|
|
{
|
|
userId: context.user.id,
|
|
},
|
|
)
|
|
}),
|
|
)
|
|
session.close()
|
|
}
|
|
return neo4jgraphql(object, params, context, resolveInfo, false)
|
|
},
|
|
},
|
|
}
|