push code len ne
This commit is contained in:
@@ -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,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user