Files
speckle-server/packages/server/modules/comments/graph/resolvers/permissions.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

37 lines
1.1 KiB
TypeScript

import type { Resolvers } from '@/modules/core/graph/generated/graphql'
import { Authz } from '@speckle/shared'
export default {
Comment: {
permissions: async (parent) => ({
commentId: parent.id,
projectId: parent.streamId
})
},
CommentPermissionChecks: {
canArchive: async (parent, _args, ctx) => {
const canArchive = await ctx.authPolicies.project.comment.canArchive({
...parent,
userId: ctx.userId
})
return Authz.toGraphqlResult(canArchive)
}
},
ProjectPermissionChecks: {
canCreateComment: async (parent, _args, ctx) => {
const canCreateComment = await ctx.authPolicies.project.comment.canCreate({
...parent,
userId: ctx.userId
})
return Authz.toGraphqlResult(canCreateComment)
},
canBroadcastActivity: async (parent, _args, ctx) => {
const canBroadcastActivity = await ctx.authPolicies.project.canBroadcastActivity({
...parent,
userId: ctx.userId
})
return Authz.toGraphqlResult(canBroadcastActivity)
}
}
} as Resolvers