UNPKG

@vendure/core

Version:

A modern, headless ecommerce framework

113 lines 6.02 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CountryResolver = void 0; const graphql_1 = require("@nestjs/graphql"); const generated_types_1 = require("@vendure/common/lib/generated-types"); const country_entity_1 = require("../../../entity/region/country.entity"); const country_service_1 = require("../../../service/services/country.service"); const request_context_1 = require("../../common/request-context"); const allow_decorator_1 = require("../../decorators/allow.decorator"); const relations_decorator_1 = require("../../decorators/relations.decorator"); const request_context_decorator_1 = require("../../decorators/request-context.decorator"); const transaction_decorator_1 = require("../../decorators/transaction.decorator"); let CountryResolver = class CountryResolver { constructor(countryService) { this.countryService = countryService; } countries(ctx, args, relations) { return this.countryService.findAll(ctx, args.options || undefined, relations); } async country(ctx, args, relations) { return this.countryService.findOne(ctx, args.id, relations); } async createCountry(ctx, args) { return this.countryService.create(ctx, args.input); } async updateCountry(ctx, args) { return this.countryService.update(ctx, args.input); } async deleteCountry(ctx, args) { return this.countryService.delete(ctx, args.id); } async deleteCountries(ctx, args) { return Promise.all(args.ids.map(id => this.countryService.delete(ctx, id))); } }; exports.CountryResolver = CountryResolver; __decorate([ (0, graphql_1.Query)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.ReadSettings, generated_types_1.Permission.ReadCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __param(2, (0, relations_decorator_1.Relations)(country_entity_1.Country)), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object, Array]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "countries", null); __decorate([ (0, graphql_1.Query)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.ReadSettings, generated_types_1.Permission.ReadCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __param(2, (0, relations_decorator_1.Relations)(country_entity_1.Country)), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object, Array]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "country", null); __decorate([ (0, transaction_decorator_1.Transaction)(), (0, graphql_1.Mutation)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.CreateSettings, generated_types_1.Permission.CreateCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "createCountry", null); __decorate([ (0, transaction_decorator_1.Transaction)(), (0, graphql_1.Mutation)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.UpdateSettings, generated_types_1.Permission.UpdateCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "updateCountry", null); __decorate([ (0, transaction_decorator_1.Transaction)(), (0, graphql_1.Mutation)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.DeleteSettings, generated_types_1.Permission.DeleteCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "deleteCountry", null); __decorate([ (0, transaction_decorator_1.Transaction)(), (0, graphql_1.Mutation)(), (0, allow_decorator_1.Allow)(generated_types_1.Permission.DeleteSettings, generated_types_1.Permission.DeleteCountry), __param(0, (0, request_context_decorator_1.Ctx)()), __param(1, (0, graphql_1.Args)()), __metadata("design:type", Function), __metadata("design:paramtypes", [request_context_1.RequestContext, Object]), __metadata("design:returntype", Promise) ], CountryResolver.prototype, "deleteCountries", null); exports.CountryResolver = CountryResolver = __decorate([ (0, graphql_1.Resolver)('Country'), __metadata("design:paramtypes", [country_service_1.CountryService]) ], CountryResolver); //# sourceMappingURL=country.resolver.js.map