@tinkerstack/graphql-annotation 0.0.2 → 0.0.4
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/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @tinkerstack/graphql-annotation@0.0.
|
|
2
|
+
> @tinkerstack/graphql-annotation@0.0.4 build C:\Users\mori\Documents\Work\tinkerstack\packages\graphql-annotation
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist\index.js [22m[32m21.
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
-
[32mESM[39m [1mdist\index.mjs [22m[32m19.
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m [1mdist\index.js [22m[32m21.41 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 137ms
|
|
15
|
+
[32mESM[39m [1mdist\index.mjs [22m[32m19.48 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 137ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist\index.d.mts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist\index.d.ts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 3496ms
|
|
19
|
+
[32mDTS[39m [1mdist\index.d.mts [22m[32m3.00 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist\index.d.ts [22m[32m3.00 KB[39m
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,8 @@ declare function Annotate(name: string, opts?: {
|
|
|
10
10
|
declare function Annotate(name: string, opts: {
|
|
11
11
|
data?: Record<string, any>;
|
|
12
12
|
parameter: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
type?: () => any;
|
|
13
15
|
}): ParameterDecorator & MethodDecorator;
|
|
14
16
|
declare function ResolveAnnotation(): MethodDecorator;
|
|
15
17
|
declare function ResolveAnnotation(annotation: string): MethodDecorator;
|
|
@@ -56,7 +58,9 @@ declare class GraphQLAnnotatedSchemaLoader {
|
|
|
56
58
|
private readonly externalContextCreator;
|
|
57
59
|
private _logger;
|
|
58
60
|
constructor(resolverDiscoveryService: ResolverDiscoveryService, metadataScanner: MetadataScanner, externalContextCreator: ExternalContextCreator);
|
|
59
|
-
load(sources: AnnotationSchemaSources
|
|
61
|
+
load(sources: AnnotationSchemaSources, opts?: {
|
|
62
|
+
ignoreMissingSources?: boolean;
|
|
63
|
+
}): Promise<GraphQLSchema>;
|
|
60
64
|
private discoverAnnotationResolvers;
|
|
61
65
|
private batchLoadSources;
|
|
62
66
|
private loadAnnotations;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ declare function Annotate(name: string, opts?: {
|
|
|
10
10
|
declare function Annotate(name: string, opts: {
|
|
11
11
|
data?: Record<string, any>;
|
|
12
12
|
parameter: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
type?: () => any;
|
|
13
15
|
}): ParameterDecorator & MethodDecorator;
|
|
14
16
|
declare function ResolveAnnotation(): MethodDecorator;
|
|
15
17
|
declare function ResolveAnnotation(annotation: string): MethodDecorator;
|
|
@@ -56,7 +58,9 @@ declare class GraphQLAnnotatedSchemaLoader {
|
|
|
56
58
|
private readonly externalContextCreator;
|
|
57
59
|
private _logger;
|
|
58
60
|
constructor(resolverDiscoveryService: ResolverDiscoveryService, metadataScanner: MetadataScanner, externalContextCreator: ExternalContextCreator);
|
|
59
|
-
load(sources: AnnotationSchemaSources
|
|
61
|
+
load(sources: AnnotationSchemaSources, opts?: {
|
|
62
|
+
ignoreMissingSources?: boolean;
|
|
63
|
+
}): Promise<GraphQLSchema>;
|
|
60
64
|
private discoverAnnotationResolvers;
|
|
61
65
|
private batchLoadSources;
|
|
62
66
|
private loadAnnotations;
|
package/dist/index.js
CHANGED
|
@@ -328,8 +328,10 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
328
328
|
this.metadataScanner = metadataScanner;
|
|
329
329
|
this.externalContextCreator = externalContextCreator;
|
|
330
330
|
}
|
|
331
|
-
async load(sources) {
|
|
332
|
-
const loadedSources = await this.batchLoadSources(sources
|
|
331
|
+
async load(sources, opts) {
|
|
332
|
+
const loadedSources = await this.batchLoadSources(sources, {
|
|
333
|
+
ignoreMissingSources: opts?.ignoreMissingSources ?? false
|
|
334
|
+
});
|
|
333
335
|
const schema = (0, import_stitch.stitchSchemas)({
|
|
334
336
|
subschemas: loadedSources.map((s) => s.subschema)
|
|
335
337
|
});
|
|
@@ -349,7 +351,7 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
349
351
|
}
|
|
350
352
|
return annotationResolvers;
|
|
351
353
|
}
|
|
352
|
-
async batchLoadSources(sources) {
|
|
354
|
+
async batchLoadSources(sources, opts) {
|
|
353
355
|
const pending = Object.entries(sources).map(async ([name, url]) => {
|
|
354
356
|
const loadId = `${name}@${url}`;
|
|
355
357
|
try {
|
|
@@ -371,7 +373,11 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
371
373
|
}
|
|
372
374
|
});
|
|
373
375
|
const [loaded, failed] = split(await Promise.allSettled(pending), (q) => q.status === "fulfilled");
|
|
374
|
-
|
|
376
|
+
const shouldThrow = opts?.ignoreMissingSources ?? true;
|
|
377
|
+
if (failed.length > 0) {
|
|
378
|
+
if (shouldThrow) throw new Error(`Failed to load ${failed.length} schema(s) from sources.`);
|
|
379
|
+
else this._logger.warn(`Failed to load ${failed.length}, ignoring.`);
|
|
380
|
+
}
|
|
375
381
|
return loaded.map((l) => l.value);
|
|
376
382
|
}
|
|
377
383
|
async loadAnnotations(url) {
|
package/dist/index.mjs
CHANGED
|
@@ -299,8 +299,10 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
299
299
|
this.metadataScanner = metadataScanner;
|
|
300
300
|
this.externalContextCreator = externalContextCreator;
|
|
301
301
|
}
|
|
302
|
-
async load(sources) {
|
|
303
|
-
const loadedSources = await this.batchLoadSources(sources
|
|
302
|
+
async load(sources, opts) {
|
|
303
|
+
const loadedSources = await this.batchLoadSources(sources, {
|
|
304
|
+
ignoreMissingSources: opts?.ignoreMissingSources ?? false
|
|
305
|
+
});
|
|
304
306
|
const schema = stitchSchemas({
|
|
305
307
|
subschemas: loadedSources.map((s) => s.subschema)
|
|
306
308
|
});
|
|
@@ -320,7 +322,7 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
320
322
|
}
|
|
321
323
|
return annotationResolvers;
|
|
322
324
|
}
|
|
323
|
-
async batchLoadSources(sources) {
|
|
325
|
+
async batchLoadSources(sources, opts) {
|
|
324
326
|
const pending = Object.entries(sources).map(async ([name, url]) => {
|
|
325
327
|
const loadId = `${name}@${url}`;
|
|
326
328
|
try {
|
|
@@ -342,7 +344,11 @@ var GraphQLAnnotatedSchemaLoader = class {
|
|
|
342
344
|
}
|
|
343
345
|
});
|
|
344
346
|
const [loaded, failed] = split(await Promise.allSettled(pending), (q) => q.status === "fulfilled");
|
|
345
|
-
|
|
347
|
+
const shouldThrow = opts?.ignoreMissingSources ?? true;
|
|
348
|
+
if (failed.length > 0) {
|
|
349
|
+
if (shouldThrow) throw new Error(`Failed to load ${failed.length} schema(s) from sources.`);
|
|
350
|
+
else this._logger.warn(`Failed to load ${failed.length}, ignoring.`);
|
|
351
|
+
}
|
|
346
352
|
return loaded.map((l) => l.value);
|
|
347
353
|
}
|
|
348
354
|
async loadAnnotations(url) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkerstack/graphql-annotation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Better type-safe-able graphql directives",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"@graphql-tools/stitch": "^10.1.8",
|
|
15
15
|
"@graphql-tools/utils": "^11.0.0",
|
|
16
16
|
"@graphql-tools/wrap": "^11.1.4",
|
|
17
|
-
"class-transformer": "^0.5.1",
|
|
18
17
|
"graphql-request": "^7.2.0"
|
|
19
18
|
},
|
|
20
19
|
"publishConfig": {
|
|
@@ -40,6 +39,7 @@
|
|
|
40
39
|
"@nestjs/mapped-types": "^2.1.0",
|
|
41
40
|
"@nestjs/platform-fastify": "^11.1.11",
|
|
42
41
|
"@swc/core": "^1.15.11",
|
|
42
|
+
"class-transformer": "^0.5.1",
|
|
43
43
|
"class-validator": "^0.14.2",
|
|
44
44
|
"concurrently": "^9.2.1",
|
|
45
45
|
"eslint": "^9.37.0",
|
|
@@ -30,7 +30,12 @@ export function Annotate(
|
|
|
30
30
|
*/
|
|
31
31
|
export function Annotate(
|
|
32
32
|
name: string,
|
|
33
|
-
opts: {
|
|
33
|
+
opts: {
|
|
34
|
+
data?: Record<string, any>;
|
|
35
|
+
parameter: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
type?: () => any;
|
|
38
|
+
},
|
|
34
39
|
): ParameterDecorator & MethodDecorator;
|
|
35
40
|
/**
|
|
36
41
|
* Applies an annotation to a Query or Mutation handler or parameter for
|
|
@@ -46,8 +46,13 @@ export class GraphQLAnnotatedSchemaLoader {
|
|
|
46
46
|
private readonly externalContextCreator: ExternalContextCreator,
|
|
47
47
|
) {}
|
|
48
48
|
|
|
49
|
-
public async load(
|
|
50
|
-
|
|
49
|
+
public async load(
|
|
50
|
+
sources: AnnotationSchemaSources,
|
|
51
|
+
opts?: { ignoreMissingSources?: boolean },
|
|
52
|
+
) {
|
|
53
|
+
const loadedSources = await this.batchLoadSources(sources, {
|
|
54
|
+
ignoreMissingSources: opts?.ignoreMissingSources ?? false,
|
|
55
|
+
});
|
|
51
56
|
|
|
52
57
|
const schema = stitchSchemas({
|
|
53
58
|
subschemas: loadedSources.map((s) => s.subschema),
|
|
@@ -108,7 +113,10 @@ export class GraphQLAnnotatedSchemaLoader {
|
|
|
108
113
|
return annotationResolvers;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
private async batchLoadSources(
|
|
116
|
+
private async batchLoadSources(
|
|
117
|
+
sources: AnnotationSchemaSources,
|
|
118
|
+
opts?: { ignoreMissingSources?: boolean },
|
|
119
|
+
) {
|
|
112
120
|
const pending = Object.entries(sources).map(async ([name, url]) => {
|
|
113
121
|
const loadId = `${name}@${url}`;
|
|
114
122
|
try {
|
|
@@ -140,10 +148,15 @@ export class GraphQLAnnotatedSchemaLoader {
|
|
|
140
148
|
await Promise.allSettled(pending),
|
|
141
149
|
(q) => q.status === "fulfilled",
|
|
142
150
|
);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
151
|
+
|
|
152
|
+
const shouldThrow = opts?.ignoreMissingSources ?? true;
|
|
153
|
+
if (failed.length > 0) {
|
|
154
|
+
if (shouldThrow)
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Failed to load ${failed.length} schema(s) from sources.`,
|
|
157
|
+
);
|
|
158
|
+
else this._logger.warn(`Failed to load ${failed.length}, ignoring.`);
|
|
159
|
+
}
|
|
147
160
|
|
|
148
161
|
return loaded.map((l) => l.value);
|
|
149
162
|
}
|