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