Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@graphql-modules/core");
class GraphQLModule extends core_1.GraphQLModule {
    constructor(_options, _moduleConfig) {
        const { dataSources } = _options, remainingOptions = __rest(_options, ["dataSources"]);
        super(remainingOptions, _moduleConfig);
        if (dataSources) {
            this.dataSources = dataSources;
        }
        if (remainingOptions.contextBuilder) {
            this.syncContextBuilder = remainingOptions.contextBuilder;
        }
        if (Array.isArray(remainingOptions.imports)) {
            this.dataSources = (arg) => {
                const merged = {};
                const imported = remainingOptions.imports;
                imported.forEach(graphqlModule => {
                    // isFunction @todo
                    if (graphqlModule.dataSources) {
                        const returned = graphqlModule.dataSources(arg);
                        Object.assign(merged, returned);
                    }
                });
                if (dataSources) {
                    const computedDataSources = dataSources(arg);
                    Object.assign(merged, computedDataSources);
                }
                return merged;
            };
        }
        // @note the one built in is async and weird
        if (Array.isArray(remainingOptions.imports)) {
            this.mergedContextBuilder = (context) => {
                const merged = {};
                const imported = remainingOptions.imports;
                imported.forEach(graphqlModule => {
                    if (graphqlModule.contextBuilder) {
                        const returned = graphqlModule.contextBuilder(context);
                        Object.assign(merged, returned);
                    }
                    if (graphqlModule.syncContextBuilder) {
                        const returned = graphqlModule.syncContextBuilder(context);
                        Object.assign(merged, returned);
                    }
                });
                // @todo do using option
                // if (this.contextBuilder) {
                //   const computedDataSources = this.contextBuilder(arg)
                //   Object.assign(merged, computedDataSources)
                // }
                return merged;
            };
        }
    }
}
exports.GraphQLModule = GraphQLModule;
//# sourceMappingURL=library.js.map