import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class SchemaGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('SchemaGrant', 'schemaGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'SchemaGrantFilter', 'SchemaGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SchemaGrant',
            fieldName: 'schemaGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('SchemaGrant', 'schemaGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'SchemaGrantFilter', 'SchemaGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SchemaGrant',
            fieldName: 'schemaGrant',
            document,
            variables,
            transform: (data) => ({
                schemaGrant: data.schemaGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('SchemaGrant', 'schemaGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'SchemaGrantFilter', 'SchemaGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SchemaGrant',
            fieldName: 'schemaGrant',
            document,
            variables,
            transform: (data) => ({
                schemaGrant: data.schemaGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('SchemaGrant', 'createSchemaGrant', 'schemaGrant', args.select, args.data, 'CreateSchemaGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SchemaGrant',
            fieldName: 'createSchemaGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('SchemaGrant', 'updateSchemaGrant', 'schemaGrant', args.select, args.where.id, args.data, 'UpdateSchemaGrantInput', 'id', 'schemaGrantPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SchemaGrant',
            fieldName: 'updateSchemaGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('SchemaGrant', 'deleteSchemaGrant', 'schemaGrant', {
            id: args.where.id,
        }, 'DeleteSchemaGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SchemaGrant',
            fieldName: 'deleteSchemaGrant',
            document,
            variables,
        });
    }
}
