fecf45f3bc
* chore: remove old resolvers * refactor: move generated file in code base * feature: use only necessary code in graphql * feature: implement query companies * feature: implement companies and relations * feature: implement all companies resolvers * feature: implement all people resolver * feature: add use resolvers * feature: implement resolvers for workspace and users
180 lines
7.8 KiB
TypeScript
180 lines
7.8 KiB
TypeScript
import * as TypeGraphQL from "type-graphql";
|
|
import type { GraphQLResolveInfo } from "graphql";
|
|
import { AggregatePersonArgs } from "./args/AggregatePersonArgs";
|
|
import { CreateManyPersonArgs } from "./args/CreateManyPersonArgs";
|
|
import { CreateOnePersonArgs } from "./args/CreateOnePersonArgs";
|
|
import { DeleteManyPersonArgs } from "./args/DeleteManyPersonArgs";
|
|
import { DeleteOnePersonArgs } from "./args/DeleteOnePersonArgs";
|
|
import { FindFirstPersonArgs } from "./args/FindFirstPersonArgs";
|
|
import { FindFirstPersonOrThrowArgs } from "./args/FindFirstPersonOrThrowArgs";
|
|
import { FindManyPersonArgs } from "./args/FindManyPersonArgs";
|
|
import { FindUniquePersonArgs } from "./args/FindUniquePersonArgs";
|
|
import { FindUniquePersonOrThrowArgs } from "./args/FindUniquePersonOrThrowArgs";
|
|
import { GroupByPersonArgs } from "./args/GroupByPersonArgs";
|
|
import { UpdateManyPersonArgs } from "./args/UpdateManyPersonArgs";
|
|
import { UpdateOnePersonArgs } from "./args/UpdateOnePersonArgs";
|
|
import { UpsertOnePersonArgs } from "./args/UpsertOnePersonArgs";
|
|
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
|
import { Person } from "../../../models/Person";
|
|
import { AffectedRowsOutput } from "../../outputs/AffectedRowsOutput";
|
|
import { AggregatePerson } from "../../outputs/AggregatePerson";
|
|
import { PersonGroupBy } from "../../outputs/PersonGroupBy";
|
|
|
|
@TypeGraphQL.Resolver(_of => Person)
|
|
export class PersonCrudResolver {
|
|
@TypeGraphQL.Query(_returns => AggregatePerson, {
|
|
nullable: false
|
|
})
|
|
async aggregatePerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: AggregatePersonArgs): Promise<AggregatePerson> {
|
|
return getPrismaFromContext(ctx).person.aggregate({
|
|
...args,
|
|
...transformInfoIntoPrismaArgs(info),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
|
nullable: false
|
|
})
|
|
async createManyPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: CreateManyPersonArgs): Promise<AffectedRowsOutput> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.createMany({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@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)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
|
nullable: false
|
|
})
|
|
async deleteManyPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteManyPersonArgs): Promise<AffectedRowsOutput> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.deleteMany({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Mutation(_returns => Person, {
|
|
nullable: true
|
|
})
|
|
async deleteOnePerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: DeleteOnePersonArgs): Promise<Person | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.delete({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => Person, {
|
|
nullable: true
|
|
})
|
|
async findFirstPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPersonArgs): Promise<Person | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.findFirst({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => Person, {
|
|
nullable: true
|
|
})
|
|
async findFirstPersonOrThrow(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstPersonOrThrowArgs): Promise<Person | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.findFirstOrThrow({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => [Person], {
|
|
nullable: false
|
|
})
|
|
async people(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindManyPersonArgs): Promise<Person[]> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.findMany({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => Person, {
|
|
nullable: true
|
|
})
|
|
async person(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePersonArgs): Promise<Person | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.findUnique({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => Person, {
|
|
nullable: true
|
|
})
|
|
async getPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindUniquePersonOrThrowArgs): Promise<Person | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.findUniqueOrThrow({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Query(_returns => [PersonGroupBy], {
|
|
nullable: false
|
|
})
|
|
async groupByPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: GroupByPersonArgs): Promise<PersonGroupBy[]> {
|
|
const { _count, _avg, _sum, _min, _max } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.groupBy({
|
|
...args,
|
|
...Object.fromEntries(
|
|
Object.entries({ _count, _avg, _sum, _min, _max }).filter(([_, v]) => v != null)
|
|
),
|
|
});
|
|
}
|
|
|
|
@TypeGraphQL.Mutation(_returns => AffectedRowsOutput, {
|
|
nullable: false
|
|
})
|
|
async updateManyPerson(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: UpdateManyPersonArgs): Promise<AffectedRowsOutput> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).person.updateMany({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
|
|
@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)),
|
|
});
|
|
}
|
|
|
|
@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)),
|
|
});
|
|
}
|
|
}
|