profile: dto, prisma access, resolver with dataloaders

- PrismaModule/PrismaService на pg-адаптере (Prisma 7 без движка запросов)
- DTO профиля и связей; служебные id/profileId не публикуются в GraphQL
- ProfileService — единственное место запросов к БД
- DataLoader'ы на каждый запрос: 1 SQL на профиль + по 1 на затронутую связь
- GraphQLModule.forRootAsync кладёт лоадеры в контекст
- клиент Prisma генерируется в src/, иначе сборка с rootDir src не видит его
- DATABASE_URL для api-контейнера собирается в docker-compose
This commit is contained in:
arswarog committed 2026-11-18 10:00:15 +03:00
1 parent bc135b8811
commit bc98a41614
25 files changed
+386 -32

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType({ description: 'Опыт работы' })
export class ExperienceDto {
profileId: number;
@Field(() => String, { description: 'Компания' })
company: string;
@Field(() => String, { description: 'Должность' })
position: string;
@Field(() => String, { description: 'Период работы' })
period: string;
@Field(() => [String], { description: 'Достижения' })
achievements: string[];
}
+4
View File
@@ -1 +1,5 @@
export { ExperienceDto } from './experience.dto.js';
export { LinkDto } from './link.dto.js';
export { ProfileDto } from './profile.dto.js';
export { ProjectDto } from './project.dto.js';
export { SkillDto } from './skill.dto.js';
+12
View File
@@ -0,0 +1,12 @@
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType({ description: 'Ссылка' })
export class LinkDto {
profileId: number;
@Field(() => String, { description: 'Название ресурса' })
name: string;
@Field(() => String, { description: 'Адрес ссылки' })
link: string;
}
+25 -3
View File
@@ -1,10 +1,32 @@
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
import { ExperienceDto } from './experience.dto.js';
import { LinkDto } from './link.dto.js';
import { ProjectDto } from './project.dto.js';
import { SkillDto } from './skill.dto.js';
@ObjectType({ description: 'Профиль и связанные с ним данные' })
export class ProfileDto {
@Field()
id: number;
@Field(() => String, { description: 'Имя' })
firstName: string;
@Field()
@Field(() => String, { description: 'Фамилия' })
lastName: string;
@Field(() => String, { description: 'Краткое описание' })
description: string;
@Field(() => [SkillDto], { description: 'Навыки' })
skills?: SkillDto[];
@Field(() => [LinkDto], { description: 'Ссылки на профессиональные ресурсы' })
links?: LinkDto[];
@Field(() => [ExperienceDto], { description: 'Опыт работы' })
experience?: ExperienceDto[];
@Field(() => [ProjectDto], { description: 'Проекты' })
projects?: ProjectDto[];
}
+15
View File
@@ -0,0 +1,15 @@
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType({ description: 'Проект' })
export class ProjectDto {
profileId: number;
@Field(() => String, { description: 'Название проекта' })
name: string;
@Field(() => String, { description: 'Адрес проекта или его репозитория' })
link: string;
@Field(() => String, { description: 'Описание проекта' })
description: string;
}
+9
View File
@@ -0,0 +1,9 @@
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType({ description: 'Навык' })
export class SkillDto {
profileId: number;
@Field(() => String, { description: 'Название навыка' })
name: string;
}