@gabliam/graphql-express
Version:
Graphql plugin for gabliam
36 lines (35 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphqlPlugin = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@gabliam/core");
const graphql_core_1 = require("@gabliam/graphql-core");
const web_core_1 = require("@gabliam/web-core");
const apollo_server_express_1 = require("apollo-server-express");
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = (0, debug_1.default)('Gabliam:Plugin:GraphqlPluginExpress');
let GraphqlPlugin = class GraphqlPlugin extends graphql_core_1.GraphqlCorePlugin {
async setUpAppolloServer(container, graphqlPluginConfig, apolloServer) {
debug('register Middleware', graphqlPluginConfig);
const webConfiguration = container.get(web_core_1.WebConfiguration);
await apolloServer.start();
const instance = (app, _container) => {
apolloServer.applyMiddleware({
path: graphqlPluginConfig.endpointUrl,
app,
});
};
webConfiguration.addwebConfig({
order: 50,
instance,
});
}
getApolloServer(config) {
return new apollo_server_express_1.ApolloServer(config);
}
};
GraphqlPlugin = tslib_1.__decorate([
(0, core_1.Plugin)({ dependencies: [{ name: 'ExpressPlugin', order: 'before' }] }),
(0, core_1.Scan)()
], GraphqlPlugin);
exports.GraphqlPlugin = GraphqlPlugin;