diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index 4a11d98c4..63069e393 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -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) diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 278513e2c..2d85d9eb9 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -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 diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index d9084dd90..5a72832a7 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -121,6 +121,7 @@ input _UserFilter { followedBy_none: _UserFilter followedBy_single: _UserFilter followedBy_every: _UserFilter + role_in: [UserGroup!] } type Query {