From d32c137cff5d6b030dcb713bb2c4e4f2ec02ebbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 16 Sep 2022 07:40:33 +0200 Subject: [PATCH] Implement 'locationName', 'location' in 'CreateGroup', 'UpdateGroup', and 'Group' resolvers --- backend/src/schema/resolvers/groups.js | 11 +++++++++-- webapp/graphql/groups.js | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/src/schema/resolvers/groups.js b/backend/src/schema/resolvers/groups.js index babef1d51..2f7ed4588 100644 --- a/backend/src/schema/resolvers/groups.js +++ b/backend/src/schema/resolvers/groups.js @@ -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)', }, }), }, diff --git a/webapp/graphql/groups.js b/webapp/graphql/groups.js index ddb944dde..5295b834d 100644 --- a/webapp/graphql/groups.js +++ b/webapp/graphql/groups.js @@ -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 } }