/** * ViewGrant model for ORM client * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { OrmClient } from '../client'; import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildFindOneDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder'; import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, StrictSelect, } from '../select-types'; import type { ViewGrant, ViewGrantWithRelations, ViewGrantSelect, ViewGrantFilter, ViewGrantOrderBy, CreateViewGrantInput, UpdateViewGrantInput, ViewGrantPatch, } from '../input-types'; import { connectionFieldsMap } from '../input-types'; export class ViewGrantModel { constructor(private client: OrmClient) {} findMany( args: FindManyArgs & { select: S; } & StrictSelect ): QueryBuilder<{ viewGrants: ConnectionResult>; }> { const { document, variables } = buildFindManyDocument( 'ViewGrant', 'viewGrants', args.select, { where: args?.where, orderBy: args?.orderBy as string[] | undefined, first: args?.first, last: args?.last, after: args?.after, before: args?.before, offset: args?.offset, }, 'ViewGrantFilter', 'ViewGrantOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'ViewGrant', fieldName: 'viewGrants', document, variables, }); } findFirst( args: FindFirstArgs & { select: S; } & StrictSelect ): QueryBuilder<{ viewGrant: InferSelectResult | null; }> { const { document, variables } = buildFindFirstDocument( 'ViewGrant', 'viewGrants', args.select, { where: args?.where, orderBy: args?.orderBy as string[] | undefined, }, 'ViewGrantFilter', 'ViewGrantOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'ViewGrant', fieldName: 'viewGrant', document, variables, transform: (data: { viewGrants?: { nodes?: InferSelectResult[]; }; }) => ({ viewGrant: data.viewGrants?.nodes?.[0] ?? null, }), }); } findOne( args: { id: string; select: S; } & StrictSelect ): QueryBuilder<{ viewGrant: InferSelectResult | null; }> { const { document, variables } = buildFindManyDocument( 'ViewGrant', 'viewGrants', args.select, { where: { id: { equalTo: args.id, }, }, first: 1, }, 'ViewGrantFilter', 'ViewGrantOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'ViewGrant', fieldName: 'viewGrant', document, variables, transform: (data: { viewGrants?: { nodes?: InferSelectResult[]; }; }) => ({ viewGrant: data.viewGrants?.nodes?.[0] ?? null, }), }); } create( args: CreateArgs & { select: S; } & StrictSelect ): QueryBuilder<{ createViewGrant: { viewGrant: InferSelectResult; }; }> { const { document, variables } = buildCreateDocument( 'ViewGrant', 'createViewGrant', 'viewGrant', args.select, args.data, 'CreateViewGrantInput', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'ViewGrant', fieldName: 'createViewGrant', document, variables, }); } update( args: UpdateArgs< S, { id: string; }, ViewGrantPatch > & { select: S; } & StrictSelect ): QueryBuilder<{ updateViewGrant: { viewGrant: InferSelectResult; }; }> { const { document, variables } = buildUpdateByPkDocument( 'ViewGrant', 'updateViewGrant', 'viewGrant', args.select, args.where.id, args.data, 'UpdateViewGrantInput', 'id', 'viewGrantPatch', connectionFieldsMap, undefined ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'ViewGrant', fieldName: 'updateViewGrant', document, variables, }); } delete( args: DeleteArgs< { id: string; }, S > & { select: S; } & StrictSelect ): QueryBuilder<{ deleteViewGrant: { viewGrant: InferSelectResult; }; }> { const { document, variables } = buildDeleteByPkDocument( 'ViewGrant', 'deleteViewGrant', 'viewGrant', { id: args.where.id, }, 'DeleteViewGrantInput', args.select, connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'ViewGrant', fieldName: 'deleteViewGrant', document, variables, }); } }