Fix failing cypress test

This commit is contained in:
Matt Rider 2019-07-01 18:50:24 -03:00
parent f302961376
commit b034d22732
2 changed files with 6 additions and 8 deletions

View File

@ -4,23 +4,22 @@ import fileUpload from './fileUpload'
export default { export default {
Mutation: { Mutation: {
UpdatePost: async (object, params, context, resolveInfo) => { UpdatePost: async (object, params, context, resolveInfo) => {
const { id: postId, categoryIds } = params const { categoryIds } = params
delete params.categoryIds delete params.categoryIds
params = await fileUpload(params, { file: 'imageUpload', url: 'image' }) params = await fileUpload(params, { file: 'imageUpload', url: 'image' })
const session = context.driver.session() const session = context.driver.session()
const cypherDeletePreviousRelations = ` const cypherDeletePreviousRelations = `
MATCH (post:Post { id: $postId })-[previousRelations:CATEGORIZED]->(category:Category) MATCH (post:Post { id: $params.id })-[previousRelations:CATEGORIZED]->(category:Category)
DELETE previousRelations DELETE previousRelations
RETURN post, category RETURN post, category
` `
await session.run(cypherDeletePreviousRelations, { postId }) await session.run(cypherDeletePreviousRelations, { params })
let updatePostCypher = `MATCH (post:Post {id: $postId}) let updatePostCypher = `MATCH (post:Post {id: $params.id})
SET post = $params SET post = $params
` `
if (categoryIds) { if (categoryIds && categoryIds.length) {
updatePostCypher += `WITH post updatePostCypher += `WITH post
UNWIND $categoryIds AS categoryId UNWIND $categoryIds AS categoryId
MATCH (category:Category {id: categoryId}) MATCH (category:Category {id: categoryId})
@ -28,7 +27,7 @@ export default {
` `
} }
updatePostCypher += `RETURN post` updatePostCypher += `RETURN post`
const updatePostVariables = { postId, categoryIds, params } const updatePostVariables = { categoryIds, params }
const transactionRes = await session.run(updatePostCypher, updatePostVariables) const transactionRes = await session.run(updatePostCypher, updatePostVariables)
const [post] = transactionRes.records.map(record => { const [post] = transactionRes.records.map(record => {

View File

@ -22,7 +22,6 @@ export default () => {
content content
contentExcerpt contentExcerpt
language language
image
} }
} }
`, `,