mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Assign post to current user on creation
This commit is contained in:
parent
3583259aa6
commit
ca076bbcb9
@ -11,6 +11,24 @@ export default {
|
|||||||
UpdateUser: async (resolve, root, args, context, info) => {
|
UpdateUser: async (resolve, root, args, context, info) => {
|
||||||
const result = await resolve(root, args, context, info)
|
const result = await resolve(root, args, context, info)
|
||||||
await createOrUpdateLocations(args.id, args.locationName, context.driver)
|
await createOrUpdateLocations(args.id, args.locationName, context.driver)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
CreatePost: async (resolve, root, args, context, info) => {
|
||||||
|
const result = await resolve(root, args, context, info)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const session = context.driver.session()
|
||||||
|
await session.run(
|
||||||
|
'MATCH (author:User {id: $userId}), (post:Post {id: $postId}) ' +
|
||||||
|
'MERGE (post)<-[:WROTE]-(author) ' +
|
||||||
|
'RETURN author', {
|
||||||
|
userId: context.user.id,
|
||||||
|
postId: result.id
|
||||||
|
})
|
||||||
|
session.close()
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
} catch (err) {}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user