@ptc-org/nestjs-query-graphql 2.2.0-alpha.3 → 2.2.0-alpha.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ptc-org/nestjs-query-graphql",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.4",
|
|
4
4
|
"description": "Nestjs graphql query adapter",
|
|
5
5
|
"author": "doug-martin <doug@dougamartin.com>",
|
|
6
6
|
"homepage": "https://github.com/tripss/nestjs-query#readme",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"pluralize": "^8.0.0",
|
|
40
40
|
"tslib": "^2.4.0",
|
|
41
41
|
"upper-case-first": "^2.0.2",
|
|
42
|
-
"@ptc-org/nestjs-query-core": "2.2.0-alpha.
|
|
42
|
+
"@ptc-org/nestjs-query-core": "2.2.0-alpha.4",
|
|
43
43
|
"lodash.merge": "4.6.2",
|
|
44
44
|
"reflect-metadata": "0.1.13"
|
|
45
45
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Class, FindRelationOptions, QueryService } from '@ptc-org/nestjs-query-core';
|
|
1
|
+
import { Class, FindRelationOptions, QueryService, SelectRelations } from '@ptc-org/nestjs-query-core';
|
|
2
2
|
import { NestjsQueryDataloader } from './relations.loader';
|
|
3
3
|
export type FindRelationsArgs<DTO, Relation> = {
|
|
4
4
|
dto: DTO;
|
|
5
|
-
} & FindRelationOptions<Relation>;
|
|
5
|
+
} & FindRelationOptions<Relation> & SelectRelations<Relation>;
|
|
6
6
|
type FindRelationsOpts<Relation> = Omit<FindRelationOptions<Relation>, 'filter'>;
|
|
7
7
|
export declare class FindRelationsLoader<DTO, Relation> implements NestjsQueryDataloader<DTO, FindRelationsArgs<DTO, Relation>, Relation | undefined | Error> {
|
|
8
8
|
readonly RelationDTO: Class<Relation>;
|
|
@@ -25,13 +25,14 @@ const ReadOneRelationMixin = (DTOClass, relation) => (Base) => {
|
|
|
25
25
|
const loaderName = `load${baseName}For${DTOClass.name}`;
|
|
26
26
|
const findLoader = new loader_1.FindRelationsLoader(relationDTO, relationName);
|
|
27
27
|
let ReadOneMixin = class ReadOneMixin extends Base {
|
|
28
|
-
async [_a = `find${baseName}`](dto, context, authFilter) {
|
|
28
|
+
async [_a = `find${baseName}`](dto, context, authFilter, relations) {
|
|
29
29
|
return loader_1.DataLoaderFactory.getOrCreateLoader(context, loaderName, findLoader.createLoader(this.service, {
|
|
30
30
|
withDeleted: relation.withDeleted,
|
|
31
31
|
lookedAhead: relation.enableLookAhead
|
|
32
32
|
})).load({
|
|
33
33
|
dto,
|
|
34
|
-
filter: authFilter
|
|
34
|
+
filter: authFilter,
|
|
35
|
+
relations
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
};
|
|
@@ -43,8 +44,9 @@ const ReadOneRelationMixin = (DTOClass, relation) => (Base) => {
|
|
|
43
44
|
operationGroup: auth_1.OperationGroup.READ,
|
|
44
45
|
many: false
|
|
45
46
|
})),
|
|
47
|
+
tslib_1.__param(3, (0, decorators_1.GraphQLLookAheadRelations)(DTOClass)),
|
|
46
48
|
tslib_1.__metadata("design:type", Function),
|
|
47
|
-
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
49
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Array]),
|
|
48
50
|
tslib_1.__metadata("design:returntype", Promise)
|
|
49
51
|
], ReadOneMixin.prototype, _a, null);
|
|
50
52
|
ReadOneMixin = tslib_1.__decorate([
|
|
@@ -79,11 +81,11 @@ const ReadManyRelationMixin = (DTOClass, relation) => (Base) => {
|
|
|
79
81
|
// disable keyset pagination for relations otherwise recursive paging will not work
|
|
80
82
|
const { ConnectionType: CT } = RelationQA;
|
|
81
83
|
let ReadManyMixin = class ReadManyMixin extends Base {
|
|
82
|
-
async [_a = `query${pluralBaseName}`](dto, q, context, relationFilter) {
|
|
84
|
+
async [_a = `query${pluralBaseName}`](dto, q, context, relationFilter, relations) {
|
|
83
85
|
const relationQuery = await (0, helpers_1.transformAndValidate)(RelationQA, q);
|
|
84
86
|
const relationLoader = loader_1.DataLoaderFactory.getOrCreateLoader(context, relationLoaderName, queryLoader.createLoader(this.service));
|
|
85
87
|
const relationCountLoader = loader_1.DataLoaderFactory.getOrCreateLoader(context, countRelationLoaderName, countLoader.createLoader(this.service));
|
|
86
|
-
return CT.createFromPromise((query) => relationLoader.load({ dto, query }), (0, nestjs_query_core_1.mergeQuery)(relationQuery, { filter: relationFilter }), (filter) => relationCountLoader.load({ dto, filter }));
|
|
88
|
+
return CT.createFromPromise((query) => relationLoader.load({ dto, query }), (0, nestjs_query_core_1.mergeQuery)(relationQuery, { filter: relationFilter, relations }), (filter) => relationCountLoader.load({ dto, filter }));
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
tslib_1.__decorate([
|
|
@@ -95,8 +97,9 @@ const ReadManyRelationMixin = (DTOClass, relation) => (Base) => {
|
|
|
95
97
|
operationGroup: auth_1.OperationGroup.READ,
|
|
96
98
|
many: true
|
|
97
99
|
})),
|
|
100
|
+
tslib_1.__param(4, (0, decorators_1.GraphQLLookAheadRelations)(relationDTO)),
|
|
98
101
|
tslib_1.__metadata("design:type", Function),
|
|
99
|
-
tslib_1.__metadata("design:paramtypes", [Object, RelationQA, Object, Object]),
|
|
102
|
+
tslib_1.__metadata("design:paramtypes", [Object, RelationQA, Object, Object, Array]),
|
|
100
103
|
tslib_1.__metadata("design:returntype", Promise)
|
|
101
104
|
], ReadManyMixin.prototype, _a, null);
|
|
102
105
|
ReadManyMixin = tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-relations.resolver.js","sourceRoot":"","sources":["../../../../../../packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts"],"names":[],"mappings":";;;;AACA,6CAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"read-relations.resolver.js","sourceRoot":"","sources":["../../../../../../packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts"],"names":[],"mappings":";;;;AACA,6CAA2E;AAC3E,kEAAoG;AAEpG,qCAA2C;AAC3C,yCAA0C;AAC1C,iDAAqG;AACrG,qDAA0D;AAC1D,yCAAiH;AACjH,uCAA2C;AAC3C,wCAAiD;AACjD,8DAA4E;AAC5E,uCAAgE;AAOhE,MAAM,oBAAoB,GACxB,CAAgB,QAAoB,EAAE,QAAoC,EAAE,EAAE,CAC9E,CAA6E,IAAO,EAAK,EAAE;;IACzF,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,IAAI,CAAA;KACZ;IACD,MAAM,kBAAkB,GAAG,IAAA,4BAAkB,EAAC,QAAQ,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAA;IAChC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,IAAA,oBAAW,EAAC,WAAW,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3F,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,IAAI,aAAa,CAAA;IAC3D,MAAM,UAAU,GAAG,OAAO,QAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvD,MAAM,UAAU,GAAG,IAAI,4BAAmB,CAAgB,WAAW,EAAE,YAAY,CAAC,CAAA;IAGpF,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAI;QAQvB,AAAN,KAAK,CAAC,MAAC,OAAO,QAAQ,EAAE,CAAC,CACb,GAAQ,EACP,OAAyB,EAKpC,UAA6B,EAE7B,SAAsC;YAEtC,OAAO,0BAAiB,CAAC,iBAAiB,CACxC,OAAO,EACP,UAAU,EACV,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpC,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,WAAW,EAAE,QAA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