@sonibble-creators/nest-microservice-pack
Version:
Microservice pack dependencies for NestJS
130 lines • 5.29 kB
JavaScript
;
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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageData = exports.Paginated = void 0;
const graphql_1 = require("@nestjs/graphql");
const graphql_relay_1 = __importDefault(require("graphql-relay"));
const typeMap = {};
function Paginated(type) {
const { name } = type;
if (typeMap[`${name}`])
return typeMap[`${name}`];
let Edge = class Edge {
constructor() {
this.name = `${name}Edge`;
}
};
__decorate([
(0, graphql_1.Field)({ nullable: true, description: `The cursor for ${name} pagination` }),
__metadata("design:type", String)
], Edge.prototype, "cursor", void 0);
__decorate([
(0, graphql_1.Field)(() => type, {
nullable: true,
description: `Node of the ${name} data`,
}),
__metadata("design:type", Object)
], Edge.prototype, "node", void 0);
Edge = __decorate([
(0, graphql_1.ObjectType)(`${name}Edge`, { isAbstract: true })
], Edge);
let PageInfo = class PageInfo {
};
__decorate([
(0, graphql_1.Field)({ nullable: true, description: `The start cursor for ${name}` }),
__metadata("design:type", String)
], PageInfo.prototype, "startCursor", void 0);
__decorate([
(0, graphql_1.Field)({ nullable: true, description: `The end cursor for ${name}` }),
__metadata("design:type", String)
], PageInfo.prototype, "endCursor", void 0);
__decorate([
(0, graphql_1.Field)(() => Boolean, {
description: `Whether there are more items to fetch before for ${name}`,
}),
__metadata("design:type", Boolean)
], PageInfo.prototype, "hasPreviousPage", void 0);
__decorate([
(0, graphql_1.Field)(() => Boolean, {
description: `Whether there is a next page for ${name}`,
}),
__metadata("design:type", Boolean)
], PageInfo.prototype, "hasNextPage", void 0);
PageInfo = __decorate([
(0, graphql_1.ObjectType)(`${name}PageInfo`, { isAbstract: true })
], PageInfo);
let Connection = class Connection {
constructor() {
this.name = `${name}Connection`;
}
};
__decorate([
(0, graphql_1.Field)(() => [Edge], {
nullable: true,
description: `Edges of the ${name} data`,
}),
__metadata("design:type", Array)
], Connection.prototype, "edges", void 0);
__decorate([
(0, graphql_1.Field)(() => PageInfo, {
nullable: true,
description: `Page info of the edges, like the cursor and posibillity to next or prev for ${name} data`,
}),
__metadata("design:type", PageInfo)
], Connection.prototype, "pageInfo", void 0);
Connection = __decorate([
(0, graphql_1.ObjectType)(`${name}Connection`, { isAbstract: true })
], Connection);
let Page = class Page {
constructor() {
this.name = `${name}Page`;
}
};
__decorate([
(0, graphql_1.Field)(() => Connection, { description: `The ${name} data of the page` }),
__metadata("design:type", Connection)
], Page.prototype, "page", void 0);
__decorate([
(0, graphql_1.Field)(() => PageData, {
nullable: true,
description: `The ${name} data information will be showed like count, limit, and the offset`,
}),
__metadata("design:type", PageData)
], Page.prototype, "pageData", void 0);
Page = __decorate([
(0, graphql_1.ObjectType)(`${name}Page`, { isAbstract: true })
], Page);
typeMap[`${name}`] = Page;
return typeMap[`${name}`];
}
exports.Paginated = Paginated;
let PageData = class PageData {
};
__decorate([
(0, graphql_1.Field)({ description: `Data count in the page` }),
__metadata("design:type", Number)
], PageData.prototype, "count", void 0);
__decorate([
(0, graphql_1.Field)({ description: `Limit data for the page` }),
__metadata("design:type", Number)
], PageData.prototype, "limit", void 0);
__decorate([
(0, graphql_1.Field)({ description: `The offset data will be showed next and before` }),
__metadata("design:type", Number)
], PageData.prototype, "offset", void 0);
PageData = __decorate([
(0, graphql_1.ObjectType)()
], PageData);
exports.PageData = PageData;
//# sourceMappingURL=pagination.payload.js.map