@tsed/cli-plugin-typegraphql 6.6.3 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/TypeGraphqlModule.js +0 -1
- package/lib/esm/hooks/TypeGraphqlInitHook.js +60 -34
- package/lib/esm/index.js +1 -1
- package/lib/esm/templates/datasource.template.js +27 -0
- package/lib/esm/templates/index.js +4 -0
- package/lib/esm/templates/model.template.js +21 -0
- package/lib/esm/templates/resolver.template.js +47 -0
- package/lib/esm/templates/service.template.js +23 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/hooks/TypeGraphqlInitHook.d.ts +5 -9
- package/lib/types/index.d.ts +1 -1
- package/lib/types/templates/datasource.template.d.ts +2 -0
- package/lib/types/templates/index.d.ts +4 -0
- package/lib/types/templates/model.template.d.ts +2 -0
- package/lib/types/templates/resolver.template.d.ts +2 -0
- package/lib/types/templates/service.template.d.ts +2 -0
- package/package.json +8 -5
- package/lib/esm/utils/templateDir.js +0 -2
- package/lib/types/utils/templateDir.d.ts +0 -1
- package/templates/init/src/datasources/MyDataSource.ts +0 -18
- package/templates/init/src/datasources/index.ts +0 -1
- package/templates/init/src/resolvers/index.ts +0 -3
- package/templates/init/src/resolvers/recipes/Recipe.ts +0 -27
- package/templates/init/src/resolvers/recipes/RecipeNotFoundError.ts +0 -7
- package/templates/init/src/resolvers/recipes/RecipeResolver.ts +0 -26
- package/templates/init/src/services/RecipeService.ts +0 -13
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { type InitCmdContext,
|
|
2
|
-
import {
|
|
3
|
-
export declare class TypeGraphqlInitHook {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onExec(ctx: InitCmdContext): {
|
|
7
|
-
title: string;
|
|
8
|
-
task: () => import("rxjs").Observable<unknown>;
|
|
9
|
-
}[];
|
|
1
|
+
import { type CliCommandHooks, type InitCmdContext, ProjectClient, type RenderDataContext } from "@tsed/cli";
|
|
2
|
+
import { type Task } from "@tsed/cli-core";
|
|
3
|
+
export declare class TypeGraphqlInitHook implements CliCommandHooks {
|
|
4
|
+
$alterInitSubTasks(tasks: Task[], data: InitCmdContext): Promise<Task[]>;
|
|
5
|
+
$alterProjectFiles(project: ProjectClient, data: RenderDataContext): ProjectClient;
|
|
10
6
|
}
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-plugin-typegraphql",
|
|
3
3
|
"description": "Ts.ED CLI plugin. Add TypeGraphql support.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-alpha.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"tslib": "2.7.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tsed/cli": "
|
|
33
|
-
"@tsed/cli-core": "
|
|
34
|
-
"@tsed/typescript": "
|
|
32
|
+
"@tsed/cli": "7.0.0-alpha.2",
|
|
33
|
+
"@tsed/cli-core": "7.0.0-alpha.2",
|
|
34
|
+
"@tsed/typescript": "7.0.0-alpha.2",
|
|
35
35
|
"cross-env": "7.0.3",
|
|
36
36
|
"typescript": "5.6.2",
|
|
37
37
|
"vitest": "3.2.4"
|
|
@@ -46,5 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-typegraphql",
|
|
48
48
|
"author": "Romain Lenzotti",
|
|
49
|
-
"license": "MIT"
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"tag": "alpha"
|
|
52
|
+
}
|
|
50
53
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const TEMPLATE_DIR: string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {DataSourceService} from "@tsed/typegraphql";
|
|
2
|
-
import {RESTDataSource} from "apollo-datasource-rest";
|
|
3
|
-
|
|
4
|
-
@DataSourceService()
|
|
5
|
-
export class MyDataSource extends RESTDataSource {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.baseURL = "http://localhost:8001";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
willSendRequest(request: any) {
|
|
12
|
-
request.headers.set("Authorization", this.context.token);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getMyData(id: string) {
|
|
16
|
-
return this.get(`/rest/calendars/${id}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./MyDataSource.js";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {Field, ID, ObjectType} from "type-graphql";
|
|
2
|
-
|
|
3
|
-
@ObjectType({description: "Object representing cooking recipe"})
|
|
4
|
-
export class Recipe {
|
|
5
|
-
@Field((type) => ID)
|
|
6
|
-
id: string;
|
|
7
|
-
|
|
8
|
-
@Field()
|
|
9
|
-
title: string;
|
|
10
|
-
|
|
11
|
-
@Field({nullable: true})
|
|
12
|
-
description?: string;
|
|
13
|
-
|
|
14
|
-
@Field()
|
|
15
|
-
creationDate: Date;
|
|
16
|
-
|
|
17
|
-
@Field((type) => [String])
|
|
18
|
-
ingredients: string[];
|
|
19
|
-
|
|
20
|
-
constructor(options: Partial<Recipe> = {}) {
|
|
21
|
-
options.id && (this.id = options.id);
|
|
22
|
-
options.title && (this.title = options.title);
|
|
23
|
-
options.description && (this.description = options.description);
|
|
24
|
-
options.creationDate && (this.creationDate = options.creationDate);
|
|
25
|
-
options.ingredients && (this.ingredients = options.ingredients);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {ResolverService} from "@tsed/typegraphql";
|
|
2
|
-
import {Arg, Query} from "type-graphql";
|
|
3
|
-
import {RecipeService} from "../../services/RecipeService.js";
|
|
4
|
-
import {Recipe} from "./Recipe.js";
|
|
5
|
-
import {RecipeNotFoundError} from "./RecipeNotFoundError.js";
|
|
6
|
-
|
|
7
|
-
@ResolverService(Recipe)
|
|
8
|
-
export class RecipeResolver {
|
|
9
|
-
constructor(private recipeService: RecipeService) {}
|
|
10
|
-
|
|
11
|
-
@Query((returns) => Recipe)
|
|
12
|
-
async recipe(@Arg("id") id: string) {
|
|
13
|
-
const recipe = await this.recipeService.findById(id);
|
|
14
|
-
|
|
15
|
-
if (recipe === undefined) {
|
|
16
|
-
throw new RecipeNotFoundError(id);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return recipe;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Query((returns) => [Recipe], {description: "Get all the recipes from around the world "})
|
|
23
|
-
recipes(): Promise<Recipe[]> {
|
|
24
|
-
return this.recipeService.findAll({});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {Injectable} from "@tsed/di";
|
|
2
|
-
import {Recipe} from "../resolvers.js";
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class RecipeService {
|
|
6
|
-
findById(id: string) {
|
|
7
|
-
return new Recipe({id})
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
findAll(query: any) {
|
|
11
|
-
return []
|
|
12
|
-
}
|
|
13
|
-
}
|