/** * AgentResource 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 { AgentResource, AgentResourceWithRelations, AgentResourceSelect, AgentResourceFilter, AgentResourceOrderBy, CreateAgentResourceInput, UpdateAgentResourceInput, AgentResourcePatch, } from '../input-types'; import { connectionFieldsMap } from '../input-types'; export class AgentResourceModel { constructor(private client: OrmClient) {} findMany( args: FindManyArgs & { select: S; } & StrictSelect ): QueryBuilder<{ agentResources: ConnectionResult>; }> { const { document, variables } = buildFindManyDocument( 'AgentResource', 'agentResources', 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, }, 'AgentResourceFilter', 'AgentResourceOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentResource', fieldName: 'agentResources', document, variables, }); } findFirst( args: FindFirstArgs & { select: S; } & StrictSelect ): QueryBuilder<{ agentResource: InferSelectResult | null; }> { const { document, variables } = buildFindFirstDocument( 'AgentResource', 'agentResources', args.select, { where: args?.where, orderBy: args?.orderBy as string[] | undefined, }, 'AgentResourceFilter', 'AgentResourceOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentResource', fieldName: 'agentResource', document, variables, transform: (data: { agentResources?: { nodes?: InferSelectResult[]; }; }) => ({ agentResource: data.agentResources?.nodes?.[0] ?? null, }), }); } findOne( args: { id: string; select: S; } & StrictSelect ): QueryBuilder<{ agentResource: InferSelectResult | null; }> { const { document, variables } = buildFindManyDocument( 'AgentResource', 'agentResources', args.select, { where: { id: { equalTo: args.id, }, }, first: 1, }, 'AgentResourceFilter', 'AgentResourceOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentResource', fieldName: 'agentResource', document, variables, transform: (data: { agentResources?: { nodes?: InferSelectResult[]; }; }) => ({ agentResource: data.agentResources?.nodes?.[0] ?? null, }), }); } create( args: CreateArgs & { select: S; } & StrictSelect ): QueryBuilder<{ createAgentResource: { agentResource: InferSelectResult; }; }> { const { document, variables } = buildCreateDocument( 'AgentResource', 'createAgentResource', 'agentResource', args.select, args.data, 'CreateAgentResourceInput', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentResource', fieldName: 'createAgentResource', document, variables, }); } update( args: UpdateArgs< S, { id: string; }, AgentResourcePatch > & { select: S; } & StrictSelect ): QueryBuilder<{ updateAgentResource: { agentResource: InferSelectResult; }; }> { const { document, variables } = buildUpdateByPkDocument( 'AgentResource', 'updateAgentResource', 'agentResource', args.select, args.where.id, args.data, 'UpdateAgentResourceInput', 'id', 'agentResourcePatch', connectionFieldsMap, undefined ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentResource', fieldName: 'updateAgentResource', document, variables, }); } delete( args: DeleteArgs< { id: string; }, S > & { select: S; } & StrictSelect ): QueryBuilder<{ deleteAgentResource: { agentResource: InferSelectResult; }; }> { const { document, variables } = buildDeleteByPkDocument( 'AgentResource', 'deleteAgentResource', 'agentResource', { id: args.where.id, }, 'DeleteAgentResourceInput', args.select, connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentResource', fieldName: 'deleteAgentResource', document, variables, }); } }