chore: added review changes for updating mutations and naming for descriptions
This commit is contained in:
@@ -19,8 +19,7 @@ export class UserEnvironmentsResolver {
|
|||||||
/* Mutations */
|
/* Mutations */
|
||||||
|
|
||||||
@Mutation(() => UserEnvironment, {
|
@Mutation(() => UserEnvironment, {
|
||||||
description:
|
description: 'Create a new personal user environment for given user uid',
|
||||||
'Create a new personal or global user environment for given user uid',
|
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
async createUserEnvironment(
|
async createUserEnvironment(
|
||||||
@@ -36,12 +35,8 @@ export class UserEnvironmentsResolver {
|
|||||||
description: 'JSON string of the variables object',
|
description: 'JSON string of the variables object',
|
||||||
})
|
})
|
||||||
variables: string,
|
variables: string,
|
||||||
@Args({
|
|
||||||
name: 'isGlobal',
|
|
||||||
description: 'isGlobal flag to indicate personal or global environment',
|
|
||||||
})
|
|
||||||
isGlobal: boolean,
|
|
||||||
): Promise<UserEnvironment> {
|
): Promise<UserEnvironment> {
|
||||||
|
const isGlobal = false;
|
||||||
const userEnvironment =
|
const userEnvironment =
|
||||||
await this.userEnvironmentsService.createUserEnvironment(
|
await this.userEnvironmentsService.createUserEnvironment(
|
||||||
user.uid,
|
user.uid,
|
||||||
@@ -54,8 +49,32 @@ export class UserEnvironmentsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => UserEnvironment, {
|
@Mutation(() => UserEnvironment, {
|
||||||
description:
|
description: 'Create a new global user environment for given user uid',
|
||||||
'Update a users personal or global environment based on environment id',
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
async createUserGlobalEnvironment(
|
||||||
|
@GqlUser() user: User,
|
||||||
|
@Args({
|
||||||
|
name: 'variables',
|
||||||
|
description: 'JSON string of the variables object',
|
||||||
|
})
|
||||||
|
variables: string,
|
||||||
|
): Promise<UserEnvironment> {
|
||||||
|
const isGlobal = true;
|
||||||
|
const globalEnvName: string = null;
|
||||||
|
const userEnvironment =
|
||||||
|
await this.userEnvironmentsService.createUserEnvironment(
|
||||||
|
user.uid,
|
||||||
|
globalEnvName,
|
||||||
|
variables,
|
||||||
|
isGlobal,
|
||||||
|
);
|
||||||
|
if (E.isLeft(userEnvironment)) throwErr(userEnvironment.left);
|
||||||
|
return userEnvironment.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation(() => UserEnvironment, {
|
||||||
|
description: 'Updates a users personal or global environment',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
async updateUserEnvironment(
|
async updateUserEnvironment(
|
||||||
@@ -88,7 +107,7 @@ export class UserEnvironmentsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => UserEnvironment, {
|
@Mutation(() => UserEnvironment, {
|
||||||
description: 'Deletes a users personal environment based on environment id',
|
description: 'Deletes a users personal environment',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
async deleteUserEnvironment(
|
async deleteUserEnvironment(
|
||||||
@@ -99,7 +118,7 @@ export class UserEnvironmentsResolver {
|
|||||||
type: () => ID,
|
type: () => ID,
|
||||||
})
|
})
|
||||||
id: string,
|
id: string,
|
||||||
): Promise<UserEnvironment> {
|
): Promise<boolean> {
|
||||||
const userEnvironment =
|
const userEnvironment =
|
||||||
await this.userEnvironmentsService.deleteUserEnvironment(user.uid, id);
|
await this.userEnvironmentsService.deleteUserEnvironment(user.uid, id);
|
||||||
if (E.isLeft(userEnvironment)) throwErr(userEnvironment.left);
|
if (E.isLeft(userEnvironment)) throwErr(userEnvironment.left);
|
||||||
@@ -110,7 +129,7 @@ export class UserEnvironmentsResolver {
|
|||||||
description: 'Deletes users all personal environments',
|
description: 'Deletes users all personal environments',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
async deleteUserEnvironments(@GqlUser() user: User): Promise<number> {
|
async deleteUserEnvironments(@GqlUser() user: User): Promise<void> {
|
||||||
return await this.userEnvironmentsService.deleteUserEnvironments(user.uid);
|
return await this.userEnvironmentsService.deleteUserEnvironments(user.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +137,7 @@ export class UserEnvironmentsResolver {
|
|||||||
description: 'Deletes all variables inside a users global environment',
|
description: 'Deletes all variables inside a users global environment',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
async deleteAllVariablesFromUsersGlobalEnvironment(
|
async clearGlobalEnvironments(
|
||||||
@GqlUser() user: User,
|
@GqlUser() user: User,
|
||||||
@Args({
|
@Args({
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@@ -128,10 +147,7 @@ export class UserEnvironmentsResolver {
|
|||||||
id: string,
|
id: string,
|
||||||
): Promise<UserEnvironment> {
|
): Promise<UserEnvironment> {
|
||||||
const userEnvironment =
|
const userEnvironment =
|
||||||
await this.userEnvironmentsService.deleteAllVariablesFromUsersGlobalEnvironment(
|
await this.userEnvironmentsService.clearGlobalEnvironments(user.uid, id);
|
||||||
user.uid,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
if (E.isLeft(userEnvironment)) throwErr(userEnvironment.left);
|
if (E.isLeft(userEnvironment)) throwErr(userEnvironment.left);
|
||||||
return userEnvironment.right;
|
return userEnvironment.right;
|
||||||
}
|
}
|
||||||
@@ -146,7 +162,7 @@ export class UserEnvironmentsResolver {
|
|||||||
userEnvironmentCreated(
|
userEnvironmentCreated(
|
||||||
@Args({
|
@Args({
|
||||||
name: 'userUid',
|
name: 'userUid',
|
||||||
description: 'users uid',
|
description: 'Users uid',
|
||||||
type: () => ID,
|
type: () => ID,
|
||||||
})
|
})
|
||||||
userUid: string,
|
userUid: string,
|
||||||
@@ -162,7 +178,7 @@ export class UserEnvironmentsResolver {
|
|||||||
userEnvironmentUpdated(
|
userEnvironmentUpdated(
|
||||||
@Args({
|
@Args({
|
||||||
name: 'id',
|
name: 'id',
|
||||||
description: 'environment id',
|
description: 'Environment id',
|
||||||
type: () => ID,
|
type: () => ID,
|
||||||
})
|
})
|
||||||
id: string,
|
id: string,
|
||||||
@@ -178,7 +194,7 @@ export class UserEnvironmentsResolver {
|
|||||||
userEnvironmentDeleted(
|
userEnvironmentDeleted(
|
||||||
@Args({
|
@Args({
|
||||||
name: 'id',
|
name: 'id',
|
||||||
description: 'environment id',
|
description: 'Environment id',
|
||||||
type: () => ID,
|
type: () => ID,
|
||||||
})
|
})
|
||||||
id: string,
|
id: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user