From 94c6f7a3163305ee873e96dd5143a4d253adeba3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 3 May 2025 00:08:11 +0200 Subject: [PATCH] lint fixes fix relation directive --- backend/.eslintrc.cjs | 21 +++- .../types/directive/neo4j-graphql-js.gql | 17 +-- .../enum/EmailNotificationSettingsType.gql | 2 +- backend/src/graphql/types/enum/Emotion.gql | 2 +- .../src/graphql/types/enum/ShoutTypeEnum.gql | 2 +- backend/src/graphql/types/enum/Visibility.gql | 2 +- backend/src/graphql/types/type/Comment.gql | 21 ++-- backend/src/graphql/types/type/Donations.gql | 2 +- .../src/graphql/types/type/EmailAddress.gql | 5 +- backend/src/graphql/types/type/FILED.gql | 10 +- backend/src/graphql/types/type/Group.gql | 84 ++++++------- backend/src/graphql/types/type/Image.gql | 22 ++-- backend/src/graphql/types/type/InviteCode.gql | 1 - backend/src/graphql/types/type/Location.gql | 2 +- .../{MEMBER_OF.gql => MEMBER_OF.gql.unused} | 0 backend/src/graphql/types/type/Message.gql | 21 ++-- backend/src/graphql/types/type/NOTIFIED.gql | 2 +- backend/src/graphql/types/type/Post.gql | 27 ++-- backend/src/graphql/types/type/Report.gql | 8 +- backend/src/graphql/types/type/Room.gql | 59 +++++---- backend/src/graphql/types/type/Statistics.gql | 1 - backend/src/graphql/types/type/Tag.gql | 11 +- backend/src/graphql/types/type/User.gql | 118 ++++++++++-------- backend/src/graphql/types/type/UserData.gql | 4 +- 24 files changed, 233 insertions(+), 211 deletions(-) rename backend/src/graphql/types/type/{MEMBER_OF.gql => MEMBER_OF.gql.unused} (100%) diff --git a/backend/.eslintrc.cjs b/backend/.eslintrc.cjs index e9dddef2e..aa3500965 100644 --- a/backend/.eslintrc.cjs +++ b/backend/.eslintrc.cjs @@ -176,7 +176,7 @@ module.exports = { overrides: [ { files: ['*.js', '+.cjs', '*.ts', '*.tsx'], - extends: ['plugin:security/recommended-legacy'] + extends: ['plugin:security/recommended-legacy'], }, // only for ts files { @@ -231,7 +231,24 @@ module.exports = { parser: '@graphql-eslint/eslint-plugin', plugins: ['@graphql-eslint'], extends: ['plugin:@graphql-eslint/schema-recommended'], - rules: {}, + rules: { + '@graphql-eslint/description-style': ['error', { style: 'inline' }], + '@graphql-eslint/require-description': 'off', + '@graphql-eslint/naming-convention': 'off', + '@graphql-eslint/strict-id-in-types': 'off', + '@graphql-eslint/no-typename-prefix': 'off', + // incompatible: `depends on a GraphQL validation rule "XXX" but it's not available in the "graphql" version you are using. Skipping…` + '@graphql-eslint/known-directives': 'off', + '@graphql-eslint/known-argument-names': 'off', + '@graphql-eslint/known-type-names': 'off', + '@graphql-eslint/lone-schema-definition': 'off', + '@graphql-eslint/provided-required-arguments': 'off', + '@graphql-eslint/unique-directive-names': 'off', + '@graphql-eslint/unique-directive-names-per-location': 'off', + '@graphql-eslint/unique-field-definition-names': 'off', + '@graphql-eslint/unique-operation-types': 'off', + '@graphql-eslint/unique-type-names': 'off', + }, parserOptions: { schema: './src/graphql/types/**/*.gql', assumeValid: true, diff --git a/backend/src/graphql/types/directive/neo4j-graphql-js.gql b/backend/src/graphql/types/directive/neo4j-graphql-js.gql index 74ed42a2f..671e2257f 100644 --- a/backend/src/graphql/types/directive/neo4j-graphql-js.gql +++ b/backend/src/graphql/types/directive/neo4j-graphql-js.gql @@ -1,11 +1,14 @@ +# directive @MutationMeta on FIELD_DEFINITION +# directive @isAuthenticated on FIELD_DEFINITION +# directive @hasRole on FIELD_DEFINITION +# directive @hasScope on FIELD_DEFINITION +# directive @additionalLabels on FIELD_DEFINITION + directive @cypher(statement: String) on FIELD_DEFINITION directive @relation( - name: String - direction: String + name: String + from: String + to: String + direction: String ) on FIELD_DEFINITION | OBJECT -directive @MutationMeta on FIELD_DEFINITION directive @neo4j_ignore on FIELD_DEFINITION -directive @isAuthenticated on FIELD_DEFINITION -directive @hasRole on FIELD_DEFINITION -directive @hasScope on FIELD_DEFINITION -directive @additionalLabels on FIELD_DEFINITION \ No newline at end of file diff --git a/backend/src/graphql/types/enum/EmailNotificationSettingsType.gql b/backend/src/graphql/types/enum/EmailNotificationSettingsType.gql index 70128a6b2..2a1f6a62e 100644 --- a/backend/src/graphql/types/enum/EmailNotificationSettingsType.gql +++ b/backend/src/graphql/types/enum/EmailNotificationSettingsType.gql @@ -2,4 +2,4 @@ enum EmailNotificationSettingsType { post chat group -} \ No newline at end of file +} diff --git a/backend/src/graphql/types/enum/Emotion.gql b/backend/src/graphql/types/enum/Emotion.gql index 88a436f98..3df1f03a3 100644 --- a/backend/src/graphql/types/enum/Emotion.gql +++ b/backend/src/graphql/types/enum/Emotion.gql @@ -4,4 +4,4 @@ enum Emotion { happy angry funny -} \ No newline at end of file +} diff --git a/backend/src/graphql/types/enum/ShoutTypeEnum.gql b/backend/src/graphql/types/enum/ShoutTypeEnum.gql index 87fcbc5ff..408ca28bb 100644 --- a/backend/src/graphql/types/enum/ShoutTypeEnum.gql +++ b/backend/src/graphql/types/enum/ShoutTypeEnum.gql @@ -1,3 +1,3 @@ enum ShoutTypeEnum { Post -} \ No newline at end of file +} diff --git a/backend/src/graphql/types/enum/Visibility.gql b/backend/src/graphql/types/enum/Visibility.gql index 4f9d5591a..80f60e9a0 100644 --- a/backend/src/graphql/types/enum/Visibility.gql +++ b/backend/src/graphql/types/enum/Visibility.gql @@ -2,4 +2,4 @@ enum Visibility { public friends private -} \ No newline at end of file +} diff --git a/backend/src/graphql/types/type/Comment.gql b/backend/src/graphql/types/type/Comment.gql index b1fd7a838..d29235e69 100644 --- a/backend/src/graphql/types/type/Comment.gql +++ b/backend/src/graphql/types/type/Comment.gql @@ -50,9 +50,11 @@ type Comment { isPostObservedByMe: Boolean! @cypher( statement: "MATCH (this)-[:COMMENTS]->(:Post)<-[obs:OBSERVES]-(u:User {id: $cypherParams.currentUserId}) WHERE obs.active = true RETURN COUNT(u) >= 1" - ) - postObservingUsersCount: Int! - @cypher(statement: "MATCH (this)-[:COMMENTS]->(:Post)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true AND NOT u.disabled = true AND NOT u.deleted = true RETURN COUNT(DISTINCT u)") + ) + postObservingUsersCount: Int! + @cypher( + statement: "MATCH (this)-[:COMMENTS]->(:Post)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true AND NOT u.disabled = true AND NOT u.deleted = true RETURN COUNT(DISTINCT u)" + ) } type Query { @@ -69,16 +71,7 @@ type Query { } type Mutation { - CreateComment( - id: ID - postId: ID! - content: String! - contentExcerpt: String - ): Comment - UpdateComment( - id: ID! - content: String! - contentExcerpt: String - ): Comment + CreateComment(id: ID, postId: ID!, content: String!, contentExcerpt: String): Comment + UpdateComment(id: ID!, content: String!, contentExcerpt: String): Comment DeleteComment(id: ID!): Comment } diff --git a/backend/src/graphql/types/type/Donations.gql b/backend/src/graphql/types/type/Donations.gql index 10fb8597c..efcbabf68 100644 --- a/backend/src/graphql/types/type/Donations.gql +++ b/backend/src/graphql/types/type/Donations.gql @@ -13,4 +13,4 @@ type Query { type Mutation { UpdateDonations(showDonations: Boolean, goal: Int, progress: Int): Donations -} \ No newline at end of file +} diff --git a/backend/src/graphql/types/type/EmailAddress.gql b/backend/src/graphql/types/type/EmailAddress.gql index b2e65eafa..78d516a89 100644 --- a/backend/src/graphql/types/type/EmailAddress.gql +++ b/backend/src/graphql/types/type/EmailAddress.gql @@ -22,8 +22,5 @@ type Mutation { locale: String ): User AddEmailAddress(email: String!): EmailAddress - VerifyEmailAddress( - nonce: String! - email: String! - ): EmailAddress + VerifyEmailAddress(nonce: String!, email: String!): EmailAddress } diff --git a/backend/src/graphql/types/type/FILED.gql b/backend/src/graphql/types/type/FILED.gql index 85eca951e..6e3c6d18f 100644 --- a/backend/src/graphql/types/type/FILED.gql +++ b/backend/src/graphql/types/type/FILED.gql @@ -5,7 +5,7 @@ type FILED { submitter: User } -# this list equals the strings of an array in file "webapp/constants/modals.js" +"this list equals the strings of an array in file `webapp/constants/modals.js`" enum ReasonCategory { other discrimination_etc @@ -26,5 +26,9 @@ type FiledReport { } type Mutation { - fileReport(resourceId: ID!, reasonCategory: ReasonCategory!, reasonDescription: String!): FiledReport -} \ No newline at end of file + fileReport( + resourceId: ID! + reasonCategory: ReasonCategory! + reasonDescription: String! + ): FiledReport +} diff --git a/backend/src/graphql/types/type/Group.gql b/backend/src/graphql/types/type/Group.gql index 9bcac5047..958a025fd 100644 --- a/backend/src/graphql/types/type/Group.gql +++ b/backend/src/graphql/types/type/Group.gql @@ -1,19 +1,19 @@ -enum _GroupOrdering { - id_asc - id_desc - name_asc - name_desc - slug_asc - slug_desc - locationName_asc - locationName_desc - about_asc - about_desc - createdAt_asc - createdAt_desc - updatedAt_asc - updatedAt_desc -} +# enum _GroupOrdering { +# id_asc +# id_desc +# name_asc +# name_desc +# slug_asc +# slug_desc +# locationName_asc +# locationName_desc +# about_asc +# about_desc +# createdAt_asc +# createdAt_desc +# updatedAt_asc +# updatedAt_desc +# } type Group { id: ID! @@ -39,13 +39,14 @@ type Group { categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT") myRole: GroupMemberRole # if 'null' then the current user is no member - posts: [Post] @relation(name: "IN", direction: "IN") - isMutedByMe: Boolean! @cypher(statement: "MATCH (this) RETURN EXISTS( (this)<-[:MUTED]-(:User {id: $cypherParams.currentUserId}) )") + isMutedByMe: Boolean! + @cypher( + statement: "MATCH (this) RETURN EXISTS( (this)<-[:MUTED]-(:User {id: $cypherParams.currentUserId}) )" + ) } - input _GroupFilter { AND: [_GroupFilter!] OR: [_GroupFilter!] @@ -69,20 +70,18 @@ type Query { slug: String first: Int offset: Int - # orderBy: [_GroupOrdering] # not implemented yet - # filter: _GroupFilter # not implemented yet ): [Group] + # orderBy: [_GroupOrdering] # not implemented yet + # filter: _GroupFilter # not implemented yet - GroupMembers( - id: ID! - # first: Int # not implemented yet - # offset: Int # not implemented yet - # orderBy: [_UserOrdering] # not implemented yet - # filter: _UserFilter # not implemented yet - ): [User] + GroupMembers(id: ID!): [User] + # first: Int # not implemented yet + # orderBy: [_UserOrdering] # not implemented yet + # offset: Int # not implemented yet + # filter: _UserFilter # not implemented yet GroupCount(isMember: Boolean): Int - + # AvailableGroupTypes: [GroupType]! # AvailableGroupActionRadii: [GroupActionRadius]! @@ -100,7 +99,9 @@ type Mutation { groupType: GroupType! actionRadius: GroupActionRadius! categoryIds: [ID] + # avatar: ImageInput # a group can not be created with an avatar + locationName: String # empty string '' sets it to null ): Group @@ -110,7 +111,9 @@ type Mutation { slug: String about: String description: String + # groupType: GroupType # is not possible at the moment and has to be discussed. may be in the stronger direction: public → closed → hidden + actionRadius: GroupActionRadius categoryIds: [ID] avatar: ImageInput # test this as result @@ -119,27 +122,14 @@ type Mutation { # DeleteGroup(id: ID!): Group - JoinGroup( - groupId: ID! - userId: ID! - ): User + JoinGroup(groupId: ID!, userId: ID!): User - LeaveGroup( - groupId: ID! - userId: ID! - ): User + LeaveGroup(groupId: ID!, userId: ID!): User - ChangeGroupMemberRole( - groupId: ID! - userId: ID! - roleInGroup: GroupMemberRole! - ): User + ChangeGroupMemberRole(groupId: ID!, userId: ID!, roleInGroup: GroupMemberRole!): User - RemoveUserFromGroup( - groupId: ID! - userId: ID! - ): User + RemoveUserFromGroup(groupId: ID!, userId: ID!): User muteGroup(groupId: ID!): Group - unmuteGroup(groupId: ID!): Group + unmuteGroup(groupId: ID!): Group } diff --git a/backend/src/graphql/types/type/Image.gql b/backend/src/graphql/types/type/Image.gql index f171a4b77..5eabe7d5a 100644 --- a/backend/src/graphql/types/type/Image.gql +++ b/backend/src/graphql/types/type/Image.gql @@ -1,20 +1,22 @@ type Image { - url: ID!, + url: ID! + # urlW34: String, # urlW160: String, # urlW320: String, # urlW640: String, # urlW1024: String, - alt: String, - sensitive: Boolean, - aspectRatio: Float, - type: String, + + alt: String + sensitive: Boolean + aspectRatio: Float + type: String } input ImageInput { - alt: String, - upload: Upload, - sensitive: Boolean, - aspectRatio: Float, - type: String, + alt: String + upload: Upload + sensitive: Boolean + aspectRatio: Float + type: String } diff --git a/backend/src/graphql/types/type/InviteCode.gql b/backend/src/graphql/types/type/InviteCode.gql index 3293c735b..a4878ae27 100644 --- a/backend/src/graphql/types/type/InviteCode.gql +++ b/backend/src/graphql/types/type/InviteCode.gql @@ -6,7 +6,6 @@ type InviteCode { expiresAt: String } - type Mutation { GenerateInviteCode(expiresAt: String = null): InviteCode } diff --git a/backend/src/graphql/types/type/Location.gql b/backend/src/graphql/types/type/Location.gql index d9c0ec1cc..9d3651a5e 100644 --- a/backend/src/graphql/types/type/Location.gql +++ b/backend/src/graphql/types/type/Location.gql @@ -17,7 +17,7 @@ type Location { distanceToMe: Int } -# This is not smart - we need one location for everything - use the same type everywhere! +"This is not smart - we need one location for everything - use the same type everywhere!" type LocationMapBox { id: ID! place_name: String! diff --git a/backend/src/graphql/types/type/MEMBER_OF.gql b/backend/src/graphql/types/type/MEMBER_OF.gql.unused similarity index 100% rename from backend/src/graphql/types/type/MEMBER_OF.gql rename to backend/src/graphql/types/type/MEMBER_OF.gql.unused diff --git a/backend/src/graphql/types/type/Message.gql b/backend/src/graphql/types/type/Message.gql index 16e458151..ec911e3e8 100644 --- a/backend/src/graphql/types/type/Message.gql +++ b/backend/src/graphql/types/type/Message.gql @@ -13,14 +13,17 @@ type Message { updatedAt: String content: String! - + author: User! @relation(name: "CREATED", direction: "IN") room: Room! @relation(name: "INSIDE", direction: "OUT") senderId: String! @cypher(statement: "MATCH (this)<-[:CREATED]-(user:User) RETURN user.id") username: String! @cypher(statement: "MATCH (this)<-[:CREATED]-(user:User) RETURN user.name") - avatar: String @cypher(statement: "MATCH (this)<-[:CREATED]-(:User)-[:AVATAR_IMAGE]->(image:Image) RETURN image.url") - date: String! @cypher(statement: "RETURN this.createdAt") + avatar: String + @cypher( + statement: "MATCH (this)<-[:CREATED]-(:User)-[:AVATAR_IMAGE]->(image:Image) RETURN image.url" + ) + date: String! @cypher(statement: "RETURN this.createdAt") saved: Boolean distributed: Boolean @@ -28,21 +31,13 @@ type Message { } type Mutation { - CreateMessage( - roomId: ID! - content: String! - ): Message + CreateMessage(roomId: ID!, content: String!): Message MarkMessagesAsSeen(messageIds: [String!]): Boolean } type Query { - Message( - roomId: ID!, - first: Int - offset: Int - orderBy: [_MessageOrdering] - ): [Message] + Message(roomId: ID!, first: Int, offset: Int, orderBy: [_MessageOrdering]): [Message] } type Subscription { diff --git a/backend/src/graphql/types/type/NOTIFIED.gql b/backend/src/graphql/types/type/NOTIFIED.gql index d32b4e042..0937a6f30 100644 --- a/backend/src/graphql/types/type/NOTIFIED.gql +++ b/backend/src/graphql/types/type/NOTIFIED.gql @@ -33,7 +33,7 @@ enum NotificationReason { type Query { notifications(read: Boolean, orderBy: NotificationOrdering, first: Int, offset: Int): [NOTIFIED] } - + type Mutation { markAsRead(id: ID!): NOTIFIED markAllAsRead: [NOTIFIED] diff --git a/backend/src/graphql/types/type/Post.gql b/backend/src/graphql/types/type/Post.gql index d6df09b5e..708b57639 100644 --- a/backend/src/graphql/types/type/Post.gql +++ b/backend/src/graphql/types/type/Post.gql @@ -115,7 +115,6 @@ enum _PostOrdering { eventStart_desc } - type Post { id: ID! activityId: String @@ -133,10 +132,11 @@ type Post { createdAt: String updatedAt: String language: String - pinnedAt: String @cypher( + pinnedAt: String + @cypher( statement: "MATCH (this)<-[pinned:PINNED]-(:User) WHERE NOT this.deleted = true AND NOT this.disabled = true RETURN pinned.createdAt" ) - pinnedBy: User @relation(name:"PINNED", direction: "IN") + pinnedBy: User @relation(name: "PINNED", direction: "IN") relatedContributions: [Post]! @cypher( statement: """ @@ -161,7 +161,7 @@ type Post { statement: "MATCH (this)<-[:SHOUTED]-(r:User) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)" ) - # Has the currently logged in user shouted that post? + "Has the currently logged in user shouted that post?" shoutedByCurrentUser: Boolean! @cypher( statement: "MATCH (this)<-[:SHOUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1" @@ -174,15 +174,14 @@ type Post { @cypher( statement: "MATCH (this)<-[:VIEWED_TEASER]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1" ) - + emotions: [EMOTED] emotionsCount: Int! @cypher(statement: "MATCH (this)<-[emoted:EMOTED]-(:User) RETURN COUNT(DISTINCT emoted)") group: Group @relation(name: "IN", direction: "OUT") - postType: [PostType] - @cypher(statement: "RETURN [l IN labels(this) WHERE NOT l = 'Post']") + postType: [PostType] @cypher(statement: "RETURN [l IN labels(this) WHERE NOT l = 'Post']") eventLocationName: String eventLocation: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l") @@ -194,9 +193,11 @@ type Post { isObservedByMe: Boolean! @cypher( statement: "MATCH (this)<-[obs:OBSERVES]-(u:User {id: $cypherParams.currentUserId}) WHERE obs.active = true RETURN COUNT(u) >= 1" - ) + ) observingUsersCount: Int! - @cypher(statement: "MATCH (this)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true AND NOT u.deleted = true AND NOT u.disabled = true RETURN COUNT(DISTINCT u)") + @cypher( + statement: "MATCH (this)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true AND NOT u.deleted = true AND NOT u.disabled = true RETURN COUNT(DISTINCT u)" + ) } input _PostInput { @@ -217,7 +218,7 @@ type Mutation { title: String! slug: String content: String! - image: ImageInput, + image: ImageInput visibility: Visibility language: String categoryIds: [ID] @@ -232,7 +233,7 @@ type Mutation { slug: String content: String! contentExcerpt: String - image: ImageInput, + image: ImageInput visibility: Visibility language: String categoryIds: [ID] @@ -246,9 +247,9 @@ type Mutation { unpinPost(id: ID!): Post markTeaserAsViewed(id: ID!): Post - # Shout the given Type and ID + "Shout the given Type and ID" shout(id: ID!, type: ShoutTypeEnum): Boolean! - # Unshout the given Type and ID + "Unshout the given Type and ID" unshout(id: ID!, type: ShoutTypeEnum): Boolean! toggleObservePost(id: ID!, value: Boolean!): Post! diff --git a/backend/src/graphql/types/type/Report.gql b/backend/src/graphql/types/type/Report.gql index 9a4a48c4b..45763ac59 100644 --- a/backend/src/graphql/types/type/Report.gql +++ b/backend/src/graphql/types/type/Report.gql @@ -17,7 +17,13 @@ enum ReportRule { } type Query { - reports(orderBy: ReportOrdering, first: Int, offset: Int, reviewed: Boolean, closed: Boolean): [Report] + reports( + orderBy: ReportOrdering + first: Int + offset: Int + reviewed: Boolean + closed: Boolean + ): [Report] } enum ReportOrdering { diff --git a/backend/src/graphql/types/type/Room.gql b/backend/src/graphql/types/type/Room.gql index 60d54192c..56099b798 100644 --- a/backend/src/graphql/types/type/Room.gql +++ b/backend/src/graphql/types/type/Room.gql @@ -5,7 +5,7 @@ # users_some: _UserFilter # } -# TODO change this to last message date +"TODO change this to last message date" enum _RoomOrdering { lastMessageAt_desc createdAt_desc @@ -19,41 +19,48 @@ type Room { users: [User]! @relation(name: "CHATS_IN", direction: "IN") roomId: String! @cypher(statement: "RETURN this.id") - roomName: String! @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.name") - avatar: String @cypher(statement: """ - MATCH (this)<-[:CHATS_IN]-(user:User) - WHERE NOT user.id = $cypherParams.currentUserId - OPTIONAL MATCH (user)-[:AVATAR_IMAGE]->(image:Image) - RETURN image.url - """) + roomName: String! + @cypher( + statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.name" + ) + avatar: String + @cypher( + statement: """ + MATCH (this)<-[:CHATS_IN]-(user:User) + WHERE NOT user.id = $cypherParams.currentUserId + OPTIONAL MATCH (user)-[:AVATAR_IMAGE]->(image:Image) + RETURN image.url + """ + ) lastMessageAt: String - lastMessage: Message @cypher(statement: """ - MATCH (this)<-[:INSIDE]-(message:Message) - WITH message ORDER BY message.indexId DESC LIMIT 1 - RETURN message - """) + lastMessage: Message + @cypher( + statement: """ + MATCH (this)<-[:INSIDE]-(message:Message) + WITH message ORDER BY message.indexId DESC LIMIT 1 + RETURN message + """ + ) - unreadCount: Int @cypher(statement: """ - MATCH (this)<-[:INSIDE]-(message:Message)<-[:CREATED]-(user:User) - WHERE NOT user.id = $cypherParams.currentUserId - AND NOT message.seen - RETURN count(message) - """) + unreadCount: Int + @cypher( + statement: """ + MATCH (this)<-[:INSIDE]-(message:Message)<-[:CREATED]-(user:User) + WHERE NOT user.id = $cypherParams.currentUserId + AND NOT message.seen + RETURN count(message) + """ + ) } type Mutation { - CreateRoom( - userId: ID! - ): Room + CreateRoom(userId: ID!): Room } type Query { - Room( - id: ID - orderBy: [_RoomOrdering] - ): [Room] + Room(id: ID, orderBy: [_RoomOrdering]): [Room] UnreadRooms: Int } diff --git a/backend/src/graphql/types/type/Statistics.gql b/backend/src/graphql/types/type/Statistics.gql index 3963a3e50..0067443b6 100644 --- a/backend/src/graphql/types/type/Statistics.gql +++ b/backend/src/graphql/types/type/Statistics.gql @@ -11,4 +11,3 @@ type Statistics { countFollows: Int! countShouts: Int! } - diff --git a/backend/src/graphql/types/type/Tag.gql b/backend/src/graphql/types/type/Tag.gql index 41a772e4d..500e1d8b6 100644 --- a/backend/src/graphql/types/type/Tag.gql +++ b/backend/src/graphql/types/type/Tag.gql @@ -19,7 +19,8 @@ type Tag { id: ID! taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN") taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p) RETURN COUNT(DISTINCT p)") - taggedCountUnique: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p)<-[:WROTE]-(u:User) RETURN COUNT(DISTINCT u)") + taggedCountUnique: Int! + @cypher(statement: "MATCH (this)<-[:TAGGED]-(p)<-[:WROTE]-(u:User) RETURN COUNT(DISTINCT u)") deleted: Boolean disabled: Boolean } @@ -34,11 +35,5 @@ enum _TagOrdering { } type Query { - Tag( - id: ID - first: Int - offset: Int - orderBy: [_TagOrdering] - filter: _TagFilter - ): [Tag] + Tag(id: ID, first: Int, offset: Int, orderBy: [_TagOrdering], filter: _TagFilter): [Tag] } diff --git a/backend/src/graphql/types/type/User.gql b/backend/src/graphql/types/type/User.gql index 81dd9cf5b..645b3d1d7 100644 --- a/backend/src/graphql/types/type/User.gql +++ b/backend/src/graphql/types/type/User.gql @@ -38,7 +38,8 @@ type User { id: ID! actorId: String name: String - email: String! @cypher(statement: "MATCH (this)-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e.email") + email: String! + @cypher(statement: "MATCH (this)-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e.email") slug: String! avatar: Image @relation(name: "AVATAR_IMAGE", direction: "OUT") deleted: Boolean @@ -64,64 +65,79 @@ type User { emailNotificationSettings: [EmailNotificationSettings]! @neo4j_ignore locale: String friends: [User]! @relation(name: "FRIENDS", direction: "BOTH") - friendsCount: Int! @cypher(statement: "MATCH (this)<-[:FRIENDS]->(r:User) RETURN COUNT(DISTINCT r)") + friendsCount: Int! + @cypher(statement: "MATCH (this)<-[:FRIENDS]->(r:User) RETURN COUNT(DISTINCT r)") following: [User]! @relation(name: "FOLLOWS", direction: "OUT") - followingCount: Int! @cypher(statement: "MATCH (this)-[:FOLLOWS]->(r:User) RETURN COUNT(DISTINCT r)") + followingCount: Int! + @cypher(statement: "MATCH (this)-[:FOLLOWS]->(r:User) RETURN COUNT(DISTINCT r)") followedBy: [User]! @relation(name: "FOLLOWS", direction: "IN") - followedByCount: Int! @cypher(statement: "MATCH (this)<-[:FOLLOWS]-(r:User) RETURN COUNT(DISTINCT r)") + followedByCount: Int! + @cypher(statement: "MATCH (this)<-[:FOLLOWS]-(r:User) RETURN COUNT(DISTINCT r)") inviteCodes: [InviteCode] @relation(name: "GENERATED", direction: "OUT") redeemedInviteCode: InviteCode @relation(name: "REDEEMED", direction: "OUT") - # Is the currently logged in user following that user? - followedByCurrentUser: Boolean! @cypher( - statement: """ - MATCH (this)<-[:FOLLOWS]-(u:User { id: $cypherParams.currentUserId}) - RETURN COUNT(u) >= 1 - """ - ) + "Is the currently logged in user following that user?" + followedByCurrentUser: Boolean! + @cypher( + statement: """ + MATCH (this)<-[:FOLLOWS]-(u:User { id: $cypherParams.currentUserId}) + RETURN COUNT(u) >= 1 + """ + ) - isBlocked: Boolean! @cypher( - statement: """ - MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) - RETURN COUNT(user) >= 1 - """ - ) - blocked: Boolean! @cypher( - statement: """ - MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) - RETURN COUNT(user) >= 1 - """ - ) + isBlocked: Boolean! + @cypher( + statement: """ + MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) + RETURN COUNT(user) >= 1 + """ + ) + blocked: Boolean! + @cypher( + statement: """ + MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) + RETURN COUNT(user) >= 1 + """ + ) + + isMuted: Boolean! + @cypher( + statement: """ + MATCH (this)<-[:MUTED]-(user:User { id: $cypherParams.currentUserId}) + RETURN COUNT(user) >= 1 + """ + ) - isMuted: Boolean! @cypher( - statement: """ - MATCH (this)<-[:MUTED]-(user:User { id: $cypherParams.currentUserId}) - RETURN COUNT(user) >= 1 - """ - ) - # contributions: [WrittenPost]! # contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]! # @cypher( # statement: "MATCH (this)-[w:WROTE]->(p:Post) RETURN p as Post, w.timestamp as timestamp" # ) + contributions: [Post]! @relation(name: "WROTE", direction: "OUT") - contributionsCount: Int! @cypher( - statement: """ - MATCH (this)-[:WROTE]->(r:Post) - WHERE NOT r.deleted = true AND NOT r.disabled = true - RETURN COUNT(r) - """ - ) + contributionsCount: Int! + @cypher( + statement: """ + MATCH (this)-[:WROTE]->(r:Post) + WHERE NOT r.deleted = true AND NOT r.disabled = true + RETURN COUNT(r) + """ + ) comments: [Comment]! @relation(name: "WROTE", direction: "OUT") - commentedCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(:Comment)-[:COMMENTS]->(p:Post) WHERE NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))") + commentedCount: Int! + @cypher( + statement: "MATCH (this)-[:WROTE]->(:Comment)-[:COMMENTS]->(p:Post) WHERE NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))" + ) shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") - shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)") + shoutedCount: Int! + @cypher( + statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)" + ) categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT") @@ -134,18 +150,18 @@ type User { emotions: [EMOTED] - activeCategories: [String] @cypher( - statement: """ - MATCH (category:Category) - WHERE NOT ((this)-[:NOT_INTERESTED_IN]->(category)) - RETURN collect(category.id) - """ - ) + activeCategories: [String] + @cypher( + statement: """ + MATCH (category:Category) + WHERE NOT ((this)-[:NOT_INTERESTED_IN]->(category)) + RETURN collect(category.id) + """ + ) myRoleInGroup: GroupMemberRole } - input _UserFilter { AND: [_UserFilter!] OR: [_UserFilter!] @@ -200,7 +216,7 @@ type Query { filter: _UserFilter ): [User] - availableRoles: [UserRole]! + availableRoles: [UserRole]! mutedUsers: [User] blockedUsers: [User] currentUser: User! @@ -212,7 +228,7 @@ enum Deletable { } type Mutation { - UpdateUser ( + UpdateUser( id: ID! name: String email: String @@ -242,14 +258,14 @@ type Mutation { switchUserRole(role: UserRole!, id: ID!): User saveCategorySettings(activeCategories: [String]): Boolean - + updateOnlineStatus(status: OnlineStatus!): Boolean! requestPasswordReset(email: String!): Boolean! resetPassword(email: String!, nonce: String!, newPassword: String!): Boolean! changePassword(oldPassword: String!, newPassword: String!): String! - # Get a JWT Token for the given Email and password + "Get a JWT Token for the given Email and password" login(email: String!, password: String!): String! setTrophyBadgeSelected(slot: Int!, badgeId: ID): User diff --git a/backend/src/graphql/types/type/UserData.gql b/backend/src/graphql/types/type/UserData.gql index 60ad5c12f..d0b907826 100644 --- a/backend/src/graphql/types/type/UserData.gql +++ b/backend/src/graphql/types/type/UserData.gql @@ -4,7 +4,5 @@ type UserData { } type Query { - userData( - id: ID - ): UserData + userData(id: ID): UserData }