|
|
@@ -54,10 +54,7 @@ export class CollectionResolver {
|
|
|
})
|
|
|
relations: RelationPaths<Collection>,
|
|
|
): Promise<PaginatedList<Translated<Collection>>> {
|
|
|
- return this.collectionService.findAll(ctx, args.options || undefined, relations).then(res => {
|
|
|
- res.items.forEach(this.encodeFilters);
|
|
|
- return res;
|
|
|
- });
|
|
|
+ return this.collectionService.findAll(ctx, args.options || undefined, relations);
|
|
|
}
|
|
|
|
|
|
@Query()
|
|
|
@@ -82,8 +79,7 @@ export class CollectionResolver {
|
|
|
} else {
|
|
|
throw new UserInputError(`error.collection-id-or-slug-must-be-provided`);
|
|
|
}
|
|
|
-
|
|
|
- return this.encodeFilters(collection);
|
|
|
+ return collection;
|
|
|
}
|
|
|
|
|
|
@Query()
|
|
|
@@ -102,7 +98,7 @@ export class CollectionResolver {
|
|
|
): Promise<Translated<Collection>> {
|
|
|
const { input } = args;
|
|
|
this.configurableOperationCodec.decodeConfigurableOperationIds(CollectionFilter, input.filters);
|
|
|
- return this.collectionService.create(ctx, input).then(this.encodeFilters);
|
|
|
+ return this.collectionService.create(ctx, input);
|
|
|
}
|
|
|
|
|
|
@Transaction()
|
|
|
@@ -114,7 +110,7 @@ export class CollectionResolver {
|
|
|
): Promise<Translated<Collection>> {
|
|
|
const { input } = args;
|
|
|
this.configurableOperationCodec.decodeConfigurableOperationIds(CollectionFilter, input.filters || []);
|
|
|
- return this.collectionService.update(ctx, input).then(this.encodeFilters);
|
|
|
+ return this.collectionService.update(ctx, input);
|
|
|
}
|
|
|
|
|
|
@Transaction()
|
|
|
@@ -125,7 +121,7 @@ export class CollectionResolver {
|
|
|
@Args() args: MutationMoveCollectionArgs,
|
|
|
): Promise<Translated<Collection>> {
|
|
|
const { input } = args;
|
|
|
- return this.collectionService.move(ctx, input).then(this.encodeFilters);
|
|
|
+ return this.collectionService.move(ctx, input);
|
|
|
}
|
|
|
|
|
|
@Transaction()
|
|
|
@@ -137,17 +133,4 @@ export class CollectionResolver {
|
|
|
): Promise<DeletionResponse> {
|
|
|
return this.collectionService.delete(ctx, args.id);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * Encodes any entity IDs used in the filter arguments.
|
|
|
- */
|
|
|
- private encodeFilters = <T extends Collection | undefined>(collection: T): T => {
|
|
|
- if (collection) {
|
|
|
- this.configurableOperationCodec.encodeConfigurableOperationIds(
|
|
|
- CollectionFilter,
|
|
|
- collection.filters,
|
|
|
- );
|
|
|
- }
|
|
|
- return collection;
|
|
|
- };
|
|
|
}
|