20 lines
886 B
TypeScript
20 lines
886 B
TypeScript
import * as TypeGraphQL from "type-graphql";
|
|
import type { GraphQLResolveInfo } from "graphql";
|
|
import { FindFirstCompanyArgs } from "./args/FindFirstCompanyArgs";
|
|
import { Company } from "../../../models/Company";
|
|
import { transformInfoIntoPrismaArgs, getPrismaFromContext, transformCountFieldIntoSelectRelationsCount } from "../../../helpers";
|
|
|
|
@TypeGraphQL.Resolver(_of => Company)
|
|
export class FindFirstCompanyResolver {
|
|
@TypeGraphQL.Query(_returns => Company, {
|
|
nullable: true
|
|
})
|
|
async findFirstCompany(@TypeGraphQL.Ctx() ctx: any, @TypeGraphQL.Info() info: GraphQLResolveInfo, @TypeGraphQL.Args() args: FindFirstCompanyArgs): Promise<Company | null> {
|
|
const { _count } = transformInfoIntoPrismaArgs(info);
|
|
return getPrismaFromContext(ctx).company.findFirst({
|
|
...args,
|
|
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
|
|
});
|
|
}
|
|
}
|