@zuu/owl
Version:
Zuu's Experimental GraphQL Implementation
41 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const getMetadataStorage_1 = require("../metadata/getMetadataStorage");
const errors_1 = require("../errors");
const decorators_1 = require("../helpers/decorators");
const findType_1 = require("../helpers/findType");
function FieldResolver(returnTypeFuncOrOptions, maybeOptions) {
return (prototype, propertyKey) => {
if (typeof propertyKey === "symbol") {
throw new errors_1.SymbolKeysNotSupportedError();
}
let getType;
let typeOptions;
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
try {
const typeInfo = findType_1.findType({
metadataKey: "design:returntype",
prototype,
propertyKey,
returnTypeFunc,
typeOptions: options,
});
typeOptions = typeInfo.typeOptions;
getType = typeInfo.getType;
}
catch (_a) { }
getMetadataStorage_1.getMetadataStorage().collectFieldResolverMetadata({
kind: "external",
methodName: propertyKey,
schemaName: options.name || propertyKey,
target: prototype.constructor,
handler: prototype[propertyKey],
getType,
typeOptions,
description: options.description,
deprecationReason: options.deprecationReason,
});
};
}
exports.FieldResolver = FieldResolver;
//# sourceMappingURL=FieldResolver.js.map