From 520598c89770044534a1c64f67be593a76b3b861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 3 Aug 2022 11:50:56 +0200 Subject: [PATCH] Implement 'description', 'groupType', and 'actionRadius' in 'CreateGroup' --- backend/src/db/graphql/mutations.ts | 9 ++++ .../src/middleware/slugifyMiddleware.spec.js | 8 +++ backend/src/models/Group.js | 54 +++++++++++-------- backend/src/schema/resolvers/groups.spec.js | 4 +- backend/src/schema/types/type/Group.gql | 23 ++++---- 5 files changed, 64 insertions(+), 34 deletions(-) diff --git a/backend/src/db/graphql/mutations.ts b/backend/src/db/graphql/mutations.ts index 5fc554ee2..c49856f2a 100644 --- a/backend/src/db/graphql/mutations.ts +++ b/backend/src/db/graphql/mutations.ts @@ -6,6 +6,9 @@ export const createGroupMutation = gql` $name: String!, $slug: String, $about: String, + $description: String!, + $groupType: GroupType!, + $actionRadius: GroupActionRadius!, $categoryIds: [ID] ) { CreateGroup( @@ -13,12 +16,18 @@ export const createGroupMutation = gql` name: $name slug: $slug about: $about + description: $description + groupType: $groupType + actionRadius: $actionRadius categoryIds: $categoryIds ) { id name slug about + description + groupType + actionRadius disabled deleted owner { diff --git a/backend/src/middleware/slugifyMiddleware.spec.js b/backend/src/middleware/slugifyMiddleware.spec.js index 44701970d..af6ff25b0 100644 --- a/backend/src/middleware/slugifyMiddleware.spec.js +++ b/backend/src/middleware/slugifyMiddleware.spec.js @@ -69,6 +69,9 @@ describe('slugifyMiddleware', () => { ...variables, name: 'The Best Group', about: 'Some about', + description: 'Some description', + groupType: 'closed', + actionRadius: 'national', categoryIds, } }) @@ -83,7 +86,12 @@ describe('slugifyMiddleware', () => { ).resolves.toMatchObject({ data: { CreateGroup: { + name: 'The Best Group', slug: 'the-best-group', + about: 'Some about', + description: 'Some description', + groupType: 'closed', + actionRadius: 'national', }, }, }) diff --git a/backend/src/models/Group.js b/backend/src/models/Group.js index 651c2983e..53b02fbec 100644 --- a/backend/src/models/Group.js +++ b/backend/src/models/Group.js @@ -4,19 +4,44 @@ export default { id: { type: 'string', primary: true, default: uuid }, // TODO: should be type: 'uuid' but simplified for our tests name: { type: 'string', disallow: [null], min: 3 }, slug: { type: 'string', unique: 'true', regex: /^[a-z0-9_-]+$/, lowercase: true }, + + createdAt: { + type: 'string', + isoDate: true, + required: true, + default: () => new Date().toISOString(), + }, + updatedAt: { + type: 'string', + isoDate: true, + required: true, + default: () => new Date().toISOString(), + }, + deleted: { type: 'boolean', default: false }, + disabled: { type: 'boolean', default: false }, + avatar: { type: 'relationship', relationship: 'AVATAR_IMAGE', target: 'Image', direction: 'out', }, - deleted: { type: 'boolean', default: false }, - disabled: { type: 'boolean', default: false }, - wasSeeded: 'boolean', // Wolle: used or needed? - locationName: { type: 'string', allow: [null] }, - about: { type: 'string', allow: [null, ''] }, // Wolle: null? - description: { type: 'string', allow: [null, ''] }, // Wolle: null? HTML with Tiptap, similar to post content, wie bei Posts "content: { type: 'string', disallow: [null], min: 3 },"? + + about: { type: 'string', allow: [null, ''] }, + description: { type: 'string', disallow: [null], min: 100 }, descriptionExcerpt: { type: 'string', allow: [null] }, + groupType: { type: 'string', default: 'public' }, + actionRadius: { type: 'string', default: 'regional' }, + + locationName: { type: 'string', allow: [null] }, + + wasSeeded: 'boolean', // Wolle: used or needed? + owner: { + type: 'relationship', + relationship: 'OWNS', + target: 'User', + direction: 'in', + }, // Wolle: followedBy: { // type: 'relationship', // relationship: 'FOLLOWS', @@ -26,26 +51,9 @@ export default { // createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() }, // }, // }, - owner: { - type: 'relationship', - relationship: 'OWNS', - target: 'User', - direction: 'in', - }, // Wolle: correct this way? // members: { type: 'relationship', relationship: 'MEMBERS', target: 'User', direction: 'out' }, // Wolle: needed? lastActiveAt: { type: 'string', isoDate: true }, - createdAt: { - type: 'string', - isoDate: true, - default: () => new Date().toISOString(), - }, - updatedAt: { - type: 'string', - isoDate: true, - required: true, - default: () => new Date().toISOString(), - }, // Wolle: emoted: { // type: 'relationships', // relationship: 'EMOTED', diff --git a/backend/src/schema/resolvers/groups.spec.js b/backend/src/schema/resolvers/groups.spec.js index 8d8c7c3d8..4932c2c5e 100644 --- a/backend/src/schema/resolvers/groups.spec.js +++ b/backend/src/schema/resolvers/groups.spec.js @@ -252,6 +252,9 @@ describe('CreateGroup', () => { name: 'The Best Group', slug: 'the-group', about: 'We will change the world!', + description: 'Some description', + groupType: 'public', + actionRadius: 'regional', categoryIds, } }) @@ -272,7 +275,6 @@ describe('CreateGroup', () => { const expected = { data: { CreateGroup: { - // Wolle: id: 'g589', name: 'The Best Group', slug: 'the-group', about: 'We will change the world!', diff --git a/backend/src/schema/types/type/Group.gql b/backend/src/schema/types/type/Group.gql index 310df9dbc..ee71f3e1f 100644 --- a/backend/src/schema/types/type/Group.gql +++ b/backend/src/schema/types/type/Group.gql @@ -19,27 +19,28 @@ enum _GroupOrdering { type Group { id: ID! - name: String # title + name: String! # title slug: String! - createdAt: String - updatedAt: String + createdAt: String! + updatedAt: String! deleted: Boolean disabled: Boolean avatar: Image @relation(name: "AVATAR_IMAGE", direction: "OUT") + about: String # goal + description: String! + groupType: GroupType! + actionRadius: GroupActionRadius! + location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l") locationName: String - about: String # goal - description: String - groupType: GroupType - actionRadius: GroupActionRadius categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT") # Wolle: needed? - socialMedia: [SocialMedia]! @relation(name: "OWNED_BY", direction: "IN") + # socialMedia: [SocialMedia]! @relation(name: "OWNED_BY", direction: "IN") owner: User @relation(name: "OWNS", direction: "IN") @@ -213,10 +214,12 @@ type Mutation { name: String! slug: String avatar: ImageInput - locationName: String about: String - description: String + description: String! + groupType: GroupType! + actionRadius: GroupActionRadius! categoryIds: [ID] + locationName: String ): # Wolle: add group settings # Wolle: # showShoutsPublicly: Boolean