graphql-composer
Version:
Create your GraphQL API using composition!
21 lines • 733 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeResolver = void 0;
class TypeResolver {
static resolve(obj, types) {
const points = [];
const keys = Object.keys(obj);
types.find((type, index) => {
points.push(0);
const includesCount = type.fields.filter((f) => keys.includes(f.name))
.length;
if (includesCount) {
points[index] = includesCount;
}
});
const found = types[points.indexOf(Math.max(...points))];
return found === null || found === void 0 ? void 0 : found.built;
}
}
exports.TypeResolver = TypeResolver;
//# sourceMappingURL=TypeResolver.js.map
;