Fix graphql queries
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
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)),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user