UNPKG

@terabits/grapi

Version:

Grapi Schema Generator For GraphQL Server

22 lines (21 loc) 995 B
"use strict"; exports.__esModule = true; var lodash_1 = require("../../lodash"); var MetadataMiddleware = (function () { function MetadataMiddleware() { } MetadataMiddleware.prototype.visitGrapiDataModel = function (_a) { var model = _a.model, sdlObjectType = _a.sdlObjectType; (0, lodash_1.forEach)(sdlObjectType.getDirectives(), function (directive, key) { model.setMetadata(key, (0, lodash_1.mapValues)(directive.args, function (arg) { return arg.getValue(); })); }); }; MetadataMiddleware.prototype.visitField = function (_a) { var model = _a.model, field = _a.field, sdlObjectType = _a.sdlObjectType, sdlField = _a.sdlField; (0, lodash_1.forEach)(sdlField.getDirectives(), function (directive, key) { field.setMetadata(key, (0, lodash_1.mapValues)(directive.args, function (arg) { return arg.getValue(); })); }); }; return MetadataMiddleware; }()); exports["default"] = MetadataMiddleware;