feat(content): graphql subgraph with dataloader for textbook/chapter/kp/question
- GraphQLModule: Apollo Federation 2 at /graphql - Textbook/Chapter/KnowledgePoint/Question @key with @ResolveReference - RouterAuthGuard: validate Router-Authorization header (ADR-036) - batchFind methods added to 4 repositories - Domain modules export repositories for GraphqlModule injection
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { QuestionsController } from "./questions.controller.js";
|
||||
import { QuestionsService } from "./questions.service.js";
|
||||
import { QuestionsRepository } from "./questions.repository.js";
|
||||
import { OutboxModule } from "../shared/outbox/outbox.module.js";
|
||||
|
||||
@Module({
|
||||
imports: [OutboxModule],
|
||||
controllers: [QuestionsController],
|
||||
providers: [QuestionsService],
|
||||
exports: [QuestionsService],
|
||||
providers: [QuestionsService, QuestionsRepository],
|
||||
exports: [QuestionsService, QuestionsRepository],
|
||||
})
|
||||
export class QuestionsModule {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { eq, like, or, and, count } from "drizzle-orm";
|
||||
import { eq, like, or, and, count, inArray } from "drizzle-orm";
|
||||
import { getDb } from "../config/database.js";
|
||||
import {
|
||||
questions,
|
||||
@@ -16,6 +16,14 @@ export class QuestionsRepository {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询(DataLoader @key 解析器使用,ADR-035)
|
||||
*/
|
||||
async batchFind(ids: string[]): Promise<Question[]> {
|
||||
if (ids.length === 0) return [];
|
||||
return getDb().select().from(questions).where(inArray(questions.id, ids));
|
||||
}
|
||||
|
||||
async findByKnowledgePointId(knowledgePointId: string): Promise<Question[]> {
|
||||
return getDb()
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user