mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
30 lines
883 B
JavaScript
30 lines
883 B
JavaScript
import { neo4jgraphql } from 'neo4j-graphql-js'
|
|
|
|
export default {
|
|
Mutation: {
|
|
CreateSocialMedia: async (object, params, context, resolveInfo) => {
|
|
/**
|
|
* TODO?: Creates double Nodes!
|
|
*/
|
|
const socialMedia = await neo4jgraphql(object, params, context, resolveInfo, false)
|
|
const session = context.driver.session()
|
|
await session.run(
|
|
`MATCH (owner:User {id: $userId}), (socialMedia:SocialMedia {id: $socialMediaId})
|
|
MERGE (socialMedia)<-[:OWNED]-(owner)
|
|
RETURN owner`, {
|
|
userId: context.user.id,
|
|
socialMediaId: socialMedia.id
|
|
}
|
|
)
|
|
session.close()
|
|
|
|
return socialMedia
|
|
},
|
|
DeleteSocialMedia: async (object, params, context, resolveInfo) => {
|
|
const socialMedia = await neo4jgraphql(object, params, context, resolveInfo, false)
|
|
|
|
return socialMedia
|
|
}
|
|
}
|
|
}
|