push code len ne

This commit is contained in:
2024-10-28 20:56:21 +07:00
parent 5c1d4e92af
commit ae1aa64b41
7 changed files with 267 additions and 23 deletions

View File

@@ -1,10 +1,61 @@
import { Inject, Injectable } from '@nestjs/common';
import { PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos';
import {
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos';
import { Builder } from 'src/Graphql/graphql.builder';
import { AppConfigService } from './appconfig.service';
import { PrismaService } from 'src/Prisma/prisma.service';
@Injectable()
export class AppConfigSchema extends PothosSchema {
constructor(@Inject(SchemaBuilderToken) private readonly builder: Builder) {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly appConfigService: AppConfigService,
private readonly prisma: PrismaService,
) {
super();
}
@PothosRef()
appConfig() {
return this.builder.prismaObject('Config', {
description: 'An app config',
fields: (t) => ({
id: t.exposeID('id', {
description: 'The unique identifier for the config',
}),
name: t.exposeString('name', { description: 'The name of the config' }),
key: t.exposeString('key', { description: 'The key of the config' }),
value: t.exposeString('value', {
description: 'The value of the config',
}),
visible: t.exposeBoolean('visible', {
description: 'Whether the config is visible',
}),
}),
});
}
@PothosRef()
init(): void {
this.builder.queryFields((t) => ({
appConfigs: t.prismaField({
type: [this.appConfig()],
description: 'Get all app configs',
args: this.builder.generator.findManyArgs('Config'),
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.config.findMany({
...query,
where: args.filter ?? undefined,
orderBy: args.orderBy ?? undefined,
cursor: args.cursor ?? undefined,
skip: args.skip ?? undefined,
take: args.take ?? undefined,
});
},
}),
}));
}
}

View File

@@ -0,0 +1,7 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from 'src/Prisma/prisma.service';
@Injectable()
export class AppConfigService {
constructor(private readonly prisma: PrismaService) {}
}