update posts with post type parameter

This commit is contained in:
Moriz Wahl 2023-03-29 17:36:36 +02:00
parent 2c52d08a94
commit f00b36b99e
2 changed files with 29 additions and 1 deletions

View File

@ -184,7 +184,16 @@ export default {
` `
} }
updatePostCypher += `RETURN post {.*}` if (params.postType) {
updatePostCypher += `
REMOVE post:Article
REMOVE post:Event
SET post:${params.postType}
WITH post
`
}
updatePostCypher += `RETURN post {.*, postType: filter(l IN labels(post) WHERE NOT l = "Post")}`
const updatePostVariables = { categoryIds, params } const updatePostVariables = { categoryIds, params }
try { try {
const writeTxResultPromise = session.writeTransaction(async (transaction) => { const writeTxResultPromise = session.writeTransaction(async (transaction) => {

View File

@ -354,6 +354,7 @@ describe('UpdatePost', () => {
$content: String! $content: String!
$image: ImageInput $image: ImageInput
$categoryIds: [ID] $categoryIds: [ID]
$postType: PostType
) { ) {
UpdatePost( UpdatePost(
id: $id id: $id
@ -361,6 +362,7 @@ describe('UpdatePost', () => {
content: $content content: $content
image: $image image: $image
categoryIds: $categoryIds categoryIds: $categoryIds
postType: $postType
) { ) {
id id
title title
@ -374,6 +376,7 @@ describe('UpdatePost', () => {
categories { categories {
id id
} }
postType
} }
} }
` `
@ -495,6 +498,22 @@ describe('UpdatePost', () => {
}) })
}) })
describe('post type', () => {
it.only('changes the post type', async () => {
await expect(
mutate({ mutation: updatePostMutation, variables: { ...variables, postType: 'Event' } }),
).resolves.toMatchObject({
data: {
UpdatePost: {
id: newlyCreatedPost.id,
postType: ['Event'],
},
},
errors: undefined,
})
})
})
describe.skip('params.image', () => { describe.skip('params.image', () => {
describe('is object', () => { describe('is object', () => {
beforeEach(() => { beforeEach(() => {