UNPKG

core-mvc

Version:

Simple but powerful MVC framework for NodeJS.

36 lines (35 loc) 1.73 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Result = exports.typeDefs = exports.mutation = exports.query = exports.fieldQuery = void 0; const gqlDefinitions_1 = require("./runtime/gqlDefinitions"); const controllerRegistry_1 = __importDefault(require("./runtime/controllerRegistry")); const gqlSymbols_1 = require("./runtime/gqlSymbols"); // eslint-disable-next-line @typescript-eslint/no-explicit-any const fieldQuery = (fullPath) => (target, name) => { const existingMetadata = Reflect.getMetadata(gqlSymbols_1.gqlFieldResolverSymbol, target, name) || []; Reflect.defineMetadata(gqlSymbols_1.gqlFieldResolverSymbol, [...existingMetadata, fullPath], target, name); controllerRegistry_1.default.add(target); }; exports.fieldQuery = fieldQuery; // eslint-disable-next-line @typescript-eslint/no-explicit-any const query = (path) => (target, name) => (0, exports.fieldQuery)(`Query.${path || name}`)(target, name); exports.query = query; // eslint-disable-next-line @typescript-eslint/no-explicit-any const mutation = (path) => (target, name) => (0, exports.fieldQuery)(`Mutation.${path || name}`)(target, name); exports.mutation = mutation; const typeDefs = (types) => { (0, gqlDefinitions_1.define)({ typeDefs: types }); // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars return (_target, _name) => { }; }; exports.typeDefs = typeDefs; class Result { constructor({ data, cookies, }) { this.data = data; this.cookies = cookies; } } exports.Result = Result;