Skip to content

Commit

Permalink
fix: admin resolver generate should use dynamic property
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Aug 11, 2023
1 parent 89aac00 commit 3d805a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ exports[`api-feature generator should generate the feature libraries 10`] = `
exports[`api-feature generator should generate the feature libraries 11`] = `
"import { Resolver } from '@nestjs/graphql';
import { ApiTestService } from '@proj/api/test/data-access';
import { ApiAuthGraphQLUserGuard } from '@proj/api/auth/data-access';
import { ApiAuthGraphQLAdminGuard } from '@proj/api/auth/data-access';
import { Paging } from '@proj/api/core/data-access';
import { Mutation, Query, Args } from '@nestjs/graphql';
import { UseGuards } from '@nestjs/common';
Expand All @@ -204,7 +204,7 @@ import {
} from '@proj/api/test/data-access';
@Resolver()
@UseGuards(ApiAuthGraphQLUserGuard)
@UseGuards(ApiAuthGraphQLAdminGuard)
export class ApiTestAdminResolver {
constructor(private readonly service: ApiTestService) {}
Expand All @@ -214,8 +214,8 @@ export class ApiTestAdminResolver {
}
@Mutation(() => Boolean, { nullable: true })
adminDeleteTest(@Args('projectId') projectId: string) {
return this.service.admin.deleteTest(projectId);
adminDeleteTest(@Args('testId') testId: string) {
return this.service.admin.deleteTest(testId);
}
@Query(() => [Test], { nullable: true })
Expand All @@ -229,16 +229,16 @@ export class ApiTestAdminResolver {
}
@Query(() => Test, { nullable: true })
adminFindOneTest(@Args('projectId') projectId: string) {
return this.service.admin.findOneTest(projectId);
adminFindOneTest(@Args('testId') testId: string) {
return this.service.admin.findOneTest(testId);
}
@Mutation(() => Test, { nullable: true })
adminUpdateTest(
@Args('projectId') projectId: string,
@Args('testId') testId: string,
@Args('input') input: AdminUpdateTestInput
) {
return this.service.admin.updateTest(projectId, input);
return this.service.admin.updateTest(testId, input);
}
}
"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Resolver } from '@nestjs/graphql'
import { <%= app.className %><%= model.className %>Service } from '@<%= npmScope %>/<%= app.fileName %>/<%= model.fileName %>/data-access'
import { <%= app.className %>AuthGraphQLUserGuard } from '@<%= npmScope %>/<%= app.fileName %>/auth/data-access'
import { <%= app.className %>AuthGraphQLAdminGuard } from '@<%= npmScope %>/<%= app.fileName %>/auth/data-access'
import { Paging } from '@<%= npmScope %>/<%= app.fileName %>/core/data-access'
import { Mutation, Query, Args } from '@nestjs/graphql'
import { UseGuards } from '@nestjs/common'
Expand All @@ -12,7 +12,7 @@ import {
} from '@<%= npmScope %>/<%= app.fileName %>/<%= model.fileName %>/data-access'

@Resolver()
@UseGuards(<%= app.className %>AuthGraphQLUserGuard)
@UseGuards(<%= app.className %>AuthGraphQLAdminGuard)
export class <%= app.className %><%= model.className %><%= admin.className %>Resolver {
constructor(private readonly service: <%= app.className %><%= model.className %>Service) {}

Expand All @@ -22,8 +22,8 @@ export class <%= app.className %><%= model.className %><%= admin.className %>Res
}

@Mutation(() => Boolean, { nullable: true })
<%= admin.propertyName %>Delete<%= model.className %>(@Args('projectId') projectId: string) {
return this.service.<%= admin.propertyName %>.delete<%= model.className %>(projectId)
<%= admin.propertyName %>Delete<%= model.className %>(@Args('<%= model.propertyName %>Id') <%= model.propertyName %>Id: string) {
return this.service.<%= admin.propertyName %>.delete<%= model.className %>(<%= model.propertyName %>Id)
}

@Query(() => [<%= model.className %>], { nullable: true })
Expand All @@ -37,12 +37,12 @@ export class <%= app.className %><%= model.className %><%= admin.className %>Res
}

@Query(() => <%= model.className %>, { nullable: true })
<%= admin.propertyName %>FindOne<%= model.className %>(@Args('projectId') projectId: string) {
return this.service.<%= admin.propertyName %>.findOne<%= model.className %>(projectId)
<%= admin.propertyName %>FindOne<%= model.className %>(@Args('<%= model.propertyName %>Id') <%= model.propertyName %>Id: string) {
return this.service.<%= admin.propertyName %>.findOne<%= model.className %>(<%= model.propertyName %>Id)
}

@Mutation(() => <%= model.className %>, { nullable: true })
<%= admin.propertyName %>Update<%= model.className %>(@Args('projectId') projectId: string, @Args('input') input: <%= admin.className %>Update<%= model.className %>Input) {
return this.service.<%= admin.propertyName %>.update<%= model.className %>(projectId, input)
<%= admin.propertyName %>Update<%= model.className %>(@Args('<%= model.propertyName %>Id') <%= model.propertyName %>Id: string, @Args('input') input: <%= admin.className %>Update<%= model.className %>Input) {
return this.service.<%= admin.propertyName %>.update<%= model.className %>(<%= model.propertyName %>Id, input)
}
}

0 comments on commit 3d805a0

Please sign in to comment.