import { GqlExecutionContext } from "@nestjs/graphql";
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
export const Dto = createParamDecorator(
(data: string, context: ExecutionContext) => {
const ctx = GqlExecutionContext.create(context);
const args = ctx.getArgs();
const user = ctx.getContext().req.user;
// TODO これでぶっ込めるけど、型もあったもんじゃないし
// updateの時はuseridはいらねーな
// じゃあ、updateDtoとcreateDtoをつくるか?
// 本当は@Argsを利用したい
args[data].createdUserId = user.userId;
args[data].modifiedUserId = user.userId;
return args[data];
},
);
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme