1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.extractMetadata = void 0;
|
4 | require("reflect-metadata");
|
5 | const graphql_constants_1 = require("../graphql.constants");
|
6 | function extractMetadata(instance, prototype, methodName, filterPredicate) {
|
7 | const callback = prototype[methodName];
|
8 | const resolverType = Reflect.getMetadata(graphql_constants_1.RESOLVER_TYPE_METADATA, callback) ||
|
9 | Reflect.getMetadata(graphql_constants_1.RESOLVER_TYPE_METADATA, instance.constructor);
|
10 | const isPropertyResolver = !!Reflect.getMetadata(graphql_constants_1.RESOLVER_PROPERTY_METADATA, callback);
|
11 | const resolverName = Reflect.getMetadata(graphql_constants_1.RESOLVER_NAME_METADATA, callback);
|
12 | const isReferenceResolver = !!Reflect.getMetadata(graphql_constants_1.RESOLVER_REFERENCE_METADATA, callback);
|
13 | if (filterPredicate(resolverType, isReferenceResolver, isPropertyResolver)) {
|
14 | return null;
|
15 | }
|
16 | const name = isReferenceResolver
|
17 | ? graphql_constants_1.RESOLVER_REFERENCE_KEY
|
18 | : resolverName || methodName;
|
19 | return {
|
20 | type: resolverType,
|
21 | methodName,
|
22 | name,
|
23 | };
|
24 | }
|
25 | exports.extractMetadata = extractMetadata;
|