mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
parent
61c781c922
commit
6a01146647
@ -6,6 +6,7 @@ import statistics from './resolvers/statistics.js'
|
||||
import reports from './resolvers/reports.js'
|
||||
import posts from './resolvers/posts.js'
|
||||
import moderation from './resolvers/moderation.js'
|
||||
import follow from './resolvers/follow.js'
|
||||
import rewards from './resolvers/rewards.js'
|
||||
|
||||
export const typeDefs = fs
|
||||
@ -24,6 +25,7 @@ export const resolvers = {
|
||||
...reports.Mutation,
|
||||
...posts.Mutation,
|
||||
...moderation.Mutation,
|
||||
...follow.Mutation,
|
||||
...rewards.Mutation
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,32 @@
|
||||
import gql from 'graphql-tag'
|
||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
// import gql from 'graphql-tag'
|
||||
// import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
follow: async (object, params, context, resolveInfo) => {
|
||||
const result = await neo4jgraphql(object, params, context, resolveInfo, true)
|
||||
const { followedId, followedType } = params
|
||||
// const result = await neo4jgraphql(object, params, context, resolveInfo, true)
|
||||
const { id, type } = params
|
||||
|
||||
const session = context.driver.session()
|
||||
await session.run(
|
||||
gql`
|
||||
MATCH (n {id: $followedId}), (u:User {id: $userId})
|
||||
WHERE $type IN labels(n) AND NOT $id = $userId
|
||||
MERGE (u)-[r:FOLLOWS]->(n)
|
||||
RETURN COUNT(r) > 0`,
|
||||
let sessionRes = await session.run(
|
||||
`MATCH (node {id: $id}), (user:User {id: $userId})
|
||||
WHERE $type IN labels(node) AND NOT $id = $userId
|
||||
MERGE (user)-[relation:FOLLOWS]->(node)
|
||||
RETURN COUNT(relation) > 0 as isFollowed`,
|
||||
{
|
||||
followedId: followedId,
|
||||
type: followedType,
|
||||
id,
|
||||
type,
|
||||
userId: context.user.id
|
||||
}
|
||||
)
|
||||
|
||||
const [ isFollowed ] = sessionRes.records.map(record => {
|
||||
return record.get('isFollowed')
|
||||
})
|
||||
|
||||
session.close()
|
||||
|
||||
return result
|
||||
return isFollowed
|
||||
}
|
||||
|
||||
// unfollow: async (_object, params, context, _resolveInfo) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user