@flippico/crud-layer
v0.0.49
Published
Require install
Downloads
11
Readme
Require install
yarn add @jenyus-org/nestjs-graphql-utils apollo-server-core nestjs-typeorm-paginate
// App module
@Module({
imports: [
CrudLayerModule,
]
// ...
});
// Attachments
@ObjectType()
export class Attachments {
@Field(() => ID)
id?: string;
@Field({ nullable: true })
name: string;
}
@InputType()
export class AttachmentsMutation {
@Field({ nullable: true })
name: string;
}
// Attachments input dto
import { ID, InputType } from '@nestjs/graphql';
import { FilterableField } from '@flippico/crud-layer';
@InputType('AttachmentsInput')
export class AttachmentsInputDto {
@FilterableField(() => ID, { nullable: true })
id?: string;
@FilterableField(() => Date, { nullable: true })
createdAt?: Date;
@FilterableField(() => Date, { nullable: true })
updatedAt?: Date;
}
// Attachments service
import { Injectable } from '@nestjs/common';
import { AttachmentsEntity } from './entities/attachments.entity';
import { baseServiceGenerator } from '@flippico/crud-layer';
@Injectable()
export class AttachmentsService extends baseServiceGenerator(
AttachmentsEntity,
{
create: [],
update: [],
remove: [],
},
) {}
// Attachments resolver
import { ArgsType, Resolver } from '@nestjs/graphql';
import { findAllArgsGenerator } from '@flippico/crud-layer';
import { AttachmentsInputDto } from './dto/attachments-input.dto';
import { AttachmentsService } from './attachments.service';
@ArgsType()
export class AttachmentsFindAllFnArgs extends findAllArgsGenerator(AttachmentsInputDto) {}
@Resolver()
export class AttachmentsResolver {
constructor(private conversationChannelService: AttachmentsService) {}
}
// Feature module
@Module({
imports: [
CrudLayerModule.forFeature({
dto: Attachments,
inputDto: AttachmentsInputDto,
mutationDto: AttachmentsMutation,
typeOrmModule: [AttachmentsEntity],
}),
TypeOrmModule.forFeature([AttachmentsEntity]), // Enittty
],
providers: [AttachmentsService, AttachmentsResolver],
// ...
});