20 lines
869 B
TypeScript
20 lines
869 B
TypeScript
import * as TypeGraphQL from "type-graphql";
|
|
import type { GraphQLResolveInfo } from "graphql";
|
|
import { CreateOnePersonArgs } from "./args/CreateOnePersonArgs";
|
|
import { Person } from "../../../models/Person";
|
|
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
|
|
|
@TypeGraphQL.Resolver(_of => Person)
|
|
export class CreateOnePersonResolver {
|
|
@TypeGraphQL.Mutation(_returns => Person, {
|
|
nullable: false
|
|
})
|
|
async createOnePerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateOnePersonArgs): Promise<Person> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.create({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
}
|