-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): Various fixes to CLI add commands
- Loading branch information
1 parent
f869a17
commit 4ea7711
Showing
10 changed files
with
258 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 15 additions & 6 deletions
21
packages/cli/src/commands/add/api-extension/templates/simple-resolver.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { Permission } from '@vendure/common/lib/generated-types'; | ||
import { Allow, Ctx, RequestContext } from '@vendure/core'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
import { Allow, Ctx, RequestContext, Transaction } from '@vendure/core'; | ||
|
||
class TemplateService {} | ||
class TemplateService { | ||
async exampleQueryHandler(ctx: RequestContext, id: ID) { | ||
return true; | ||
} | ||
async exampleMutationHandler(ctx: RequestContext, id: ID) { | ||
return true; | ||
} | ||
} | ||
|
||
@Resolver() | ||
export class SimpleAdminResolver { | ||
constructor(private templateService: TemplateService) {} | ||
|
||
@Query() | ||
@Allow(Permission.SuperAdmin) | ||
async exampleQuery(@Ctx() ctx: RequestContext, @Args() args: { id: string }): Promise<boolean> { | ||
return true; | ||
async exampleQuery(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> { | ||
return this.templateService.exampleQueryHandler(ctx, args.id); | ||
} | ||
|
||
@Mutation() | ||
@Transaction() | ||
@Allow(Permission.SuperAdmin) | ||
async exampleMutation(@Ctx() ctx: RequestContext, @Args() args: { id: string }): Promise<boolean> { | ||
return true; | ||
async exampleMutation(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> { | ||
return this.templateService.exampleMutationHandler(ctx, args.id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.