mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Create UpdateComment resolver, update UpdateUser
- UpdateUser should update updatedAt at point of insertion in the database as well
This commit is contained in:
parent
ca6ae3bd1b
commit
60c473bb94
@ -78,7 +78,7 @@ const invitationLimitReached = rule({
|
||||
|
||||
const isAuthor = rule({
|
||||
cache: 'no_cache',
|
||||
})(async (parent, args, { user, driver }) => {
|
||||
})(async (_parent, args, { user, driver }) => {
|
||||
if (!user) return false
|
||||
const session = driver.session()
|
||||
const { id: resourceId } = args
|
||||
|
||||
@ -30,11 +30,24 @@ export default {
|
||||
})
|
||||
session.close()
|
||||
|
||||
const [response] = transactionRes.records.map(record => record.get('comment').properties)
|
||||
const [comment] = transactionRes.records.map(record => record.get('comment').properties)
|
||||
|
||||
return response
|
||||
return comment
|
||||
},
|
||||
DeleteComment: async (object, args, context, resolveInfo) => {
|
||||
UpdateComment: async (_parent, params, context, _resolveInfo) => {
|
||||
const session = context.driver.session()
|
||||
const updateCommentCypher = `
|
||||
MATCH (comment:Comment {id: $params.id})
|
||||
SET comment += $params
|
||||
SET comment.updatedAt = toString(datetime())
|
||||
RETURN comment
|
||||
`
|
||||
const transactionRes = await session.run(updateCommentCypher, { params })
|
||||
session.close()
|
||||
const [comment] = transactionRes.records.map(record => record.get('comment').properties)
|
||||
return comment
|
||||
},
|
||||
DeleteComment: async (_parent, args, context, _resolveInfo) => {
|
||||
const session = context.driver.session()
|
||||
const transactionRes = await session.run(
|
||||
`
|
||||
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
try {
|
||||
const user = await instance.find('User', args.id)
|
||||
if (!user) return null
|
||||
await user.update(args)
|
||||
await user.update({ ...args, updatedAt: new Date().toISOString() })
|
||||
return user.toJson()
|
||||
} catch (e) {
|
||||
throw new UserInputError(e.message)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user