mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Add custom CommentByPost query
This commit is contained in:
parent
c6b11319fe
commit
43d6254f3e
@ -23,7 +23,8 @@ export const resolvers = {
|
||||
Query: {
|
||||
...statistics.Query,
|
||||
...userManagement.Query,
|
||||
...notifications.Query
|
||||
...notifications.Query,
|
||||
...comments.Query
|
||||
},
|
||||
Mutation: {
|
||||
...userManagement.Mutation,
|
||||
|
||||
@ -1,6 +1,26 @@
|
||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
CommentByPost: async (object, params, context, resolveInfo) => {
|
||||
const { postId } = params
|
||||
|
||||
const session = context.driver.session()
|
||||
const transactionRes = await session.run(`
|
||||
MATCH (comment:Comment)-[:COMMENTS]->(post:Post {id: $postId})
|
||||
RETURN comment {.id, .contentExcerpt, .createdAt}`, {
|
||||
postId
|
||||
})
|
||||
|
||||
session.close()
|
||||
let comments = []
|
||||
transactionRes.records.map(record => {
|
||||
comments.push(record.get('comment'))
|
||||
})
|
||||
|
||||
return comments
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
CreateComment: async (object, params, context, resolveInfo) => {
|
||||
const { postId } = params
|
||||
|
||||
@ -16,6 +16,7 @@ type Query {
|
||||
LIMIT $limit
|
||||
"""
|
||||
)
|
||||
CommentByPost(postId: ID!): [Comment]!
|
||||
}
|
||||
type Mutation {
|
||||
# Get a JWT Token for the given Email and password
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user