Skip to content

Commit 1b4fa40

Browse files
authored
Expose translationProject(id) (#3525)
1 parent e524668 commit 1b4fa40

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/project/project.resolver.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type ID,
1515
IdArg,
1616
IdField,
17+
InputException,
1718
IsOnly,
1819
ListArg,
1920
mapSecuredValue,
@@ -63,6 +64,7 @@ import {
6364
ProjectListInput,
6465
ProjectListOutput,
6566
ProjectType,
67+
TranslationProject,
6668
TranslationProjectListOutput,
6769
UpdateProjectInput,
6870
UpdateProjectOutput,
@@ -106,6 +108,20 @@ export class ProjectResolver {
106108
return await projects.load(key);
107109
}
108110

111+
@Query(() => TranslationProject, {
112+
description: 'Look up a translation project by its ID',
113+
})
114+
async translationProject(
115+
@Loader(ProjectLoader) projects: LoaderOf<ProjectLoader>,
116+
@IdsAndViewArg() key: IdsAndView,
117+
): Promise<TranslationProject> {
118+
const project = await projects.load(key);
119+
if (project.type === ProjectType.Internship) {
120+
throw new InputException('Project is not a translation project');
121+
}
122+
return project;
123+
}
124+
109125
@Query(() => ProjectListOutput, {
110126
description: 'Look up projects',
111127
})

0 commit comments

Comments
 (0)