Implement 'locationName', 'location' in 'CreateGroup', 'UpdateGroup', and 'Group' resolvers

This commit is contained in:
Wolfgang Huß 2022-09-16 07:40:33 +02:00
parent 9396a61ec0
commit d32c137cff
2 changed files with 12 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import Resolver, {
convertObjectToCypherMapLiteral,
} from './helpers/Resolver'
import { mergeImage } from './images/images'
import createOrUpdateLocations from './users/location'
export default {
Query: {
@ -135,7 +136,9 @@ export default {
return group
})
try {
return await writeTxResultPromise
const group = await writeTxResultPromise
await createOrUpdateLocations(params.id, params.locationName, session)
return group
} catch (error) {
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
throw new UserInputError('Group with this slug already exists!')
@ -206,7 +209,9 @@ export default {
return group
})
try {
return await writeTxResultPromise
const group = await writeTxResultPromise
await createOrUpdateLocations(params.id, params.locationName, session)
return group
} catch (error) {
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
throw new UserInputError('Group with this slug already exists!')
@ -300,11 +305,13 @@ export default {
},
Group: {
...Resolver('Group', {
undefinedToNull: ['deleted', 'disabled', 'locationName', 'about'],
hasMany: {
categories: '-[:CATEGORIZED]->(related:Category)',
},
hasOne: {
avatar: '-[:AVATAR_IMAGE]->(related:Image)',
location: '-[:IS_IN]->(related:Location)',
},
}),
},

View File

@ -42,7 +42,7 @@ export const createGroupMutation = gql`
name
icon
}
# locationName # test this as result
locationName # test this as result
myRole
}
}
@ -90,7 +90,7 @@ export const updateGroupMutation = gql`
icon
}
# avatar # test this as result
# locationName # test this as result
locationName # test this as result
myRole
}
}
@ -155,7 +155,7 @@ export const groupQuery = gql`
avatar {
url
}
# locationName # test this as result
locationName # test this as result
myRole
}
}