mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-01-20 20:01:22 +00:00
30 lines
927 B
JavaScript
30 lines
927 B
JavaScript
import { neo4jgraphql } from 'neo4j-graphql-js'
|
|
import fileUpload from './fileUpload'
|
|
|
|
export default {
|
|
Mutation: {
|
|
UpdatePost: async (object, params, context, resolveInfo) => {
|
|
params = await fileUpload(params, { file: 'imageUpload', url: 'image' })
|
|
return neo4jgraphql(object, params, context, resolveInfo, false)
|
|
},
|
|
|
|
CreatePost: async (object, params, context, resolveInfo) => {
|
|
params = await fileUpload(params, { file: 'imageUpload', url: 'image' })
|
|
const result = await neo4jgraphql(object, params, context, resolveInfo, false)
|
|
|
|
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()
|
|
|
|
return result
|
|
}
|
|
}
|
|
}
|