feat(server): init user module (#2018)

This commit is contained in:
Himself65
2023-04-18 18:14:25 -05:00
committed by GitHub
parent c6be29f944
commit 3a053af50c
16 changed files with 540 additions and 9 deletions
+30 -1
View File
@@ -1,6 +1,10 @@
import { randomUUID } from 'node:crypto';
import {
Args,
Field,
ID,
Mutation,
ObjectType,
Query,
registerEnumType,
@@ -17,11 +21,20 @@ export enum WorkspaceType {
registerEnumType(WorkspaceType, {
name: 'WorkspaceType',
description: 'Workspace type',
valuesMap: {
Normal: {
description: 'Normal workspace',
},
Private: {
description: 'Private workspace',
},
},
});
@ObjectType()
export class Workspace implements workspaces {
@Field()
@Field(() => ID)
id!: string;
@Field({ description: 'is Public workspace' })
public!: boolean;
@@ -53,4 +66,20 @@ export class WorkspaceResolver {
where: { id },
});
}
// create workspace
@Mutation(() => Workspace, {
name: 'createWorkspace',
description: 'Create workspace',
})
async createWorkspace() {
return this.prisma.workspaces.create({
data: {
id: randomUUID(),
type: WorkspaceType.Private,
public: false,
created_at: new Date(),
},
});
}
}