Support unpinning Post

This commit is contained in:
mattwr18 2019-10-16 23:02:58 +02:00
parent dd55d11739
commit 36f6be9e36
3 changed files with 14 additions and 1 deletions

View File

@ -113,9 +113,10 @@ export default {
return post
},
UpdatePost: async (_parent, params, context, _resolveInfo) => {
const { categoryIds, pinned } = params
const { categoryIds, pinned, unpinned } = params
const { id: userId } = context.user
delete params.pinned
delete params.unpinned
delete params.categoryIds
params = await fileUpload(params, { file: 'imageUpload', url: 'image' })
const session = context.driver.session()
@ -142,6 +143,16 @@ export default {
`
}
if (unpinned) {
const cypherRemovePinnedStatus = `
MATCH ()-[previousRelations:PINNED]->(post:Post {id: $params.id})
DELETE previousRelations
RETURN post
`
await session.run(cypherRemovePinnedStatus, { params })
}
if (pinned) {
const cypherDeletePreviousRelations = `
MATCH ()-[previousRelations:PINNED]->(post:Post)

View File

@ -85,6 +85,7 @@ type Mutation {
language: String
categoryIds: [ID]
pinned: Boolean
unpinned: Boolean
): Post
DeletePost(id: ID!): Post
AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED

View File

@ -121,6 +121,7 @@ input _UserFilter {
followedBy_none: _UserFilter
followedBy_single: _UserFilter
followedBy_every: _UserFilter
role_in: [UserGroup!]
}
type Query {