Files
twenty/server/src/api/generated-graphql/resolvers/crud/Person/UpsertOnePersonResolver.ts
T
2023-05-26 00:31:43 +02:00

20 lines
869 B
TypeScript

import * as TypeGraphQL from "type-graphql";
import type { GraphQLResolveInfo } from "graphql";
import { UpsertOnePersonArgs } from "./args/UpsertOnePersonArgs";
import { Person } from "../../../models/Person";
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
@TypeGraphQL.Resolver(_of => Person)
export class UpsertOnePersonResolver {
@TypeGraphQL.Mutation(_returns => Person, {
nullable: false
})
async upsertOnePerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpsertOnePersonArgs): Promise<Person> {
const { _count } = transformInfoIntoPrismaArgs(info);
return getPrismaFromContext(ctx).person.upsert({
...args,
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
});
}
}