fix myRole field query

This commit is contained in:
Ulf Gebhardt 2026-01-15 13:07:39 +01:00
parent 81e8d12a37
commit 8a5d263c3b
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -460,6 +460,23 @@ export default {
},
},
Group: {
myRole: async (parent, _args, context: Context, _resolveInfo) => {
if (!parent.id) {
throw new Error('Can not identify selected Group!')
}
return (
await context.database.query({
query: `
MATCH (:User {id: $user.id})-[membership:MEMBER_OF]->(group:Group {id: $parent.id})
RETURN membership.role as role
`,
variables: {
user: context.user,
parent,
},
})
).records.map((r) => r.get('role'))[0]
},
inviteCodes: async (parent, _args, context: Context, _resolveInfo) => {
if (!parent.id) {
throw new Error('Can not identify selected Group!')