Skip to content

Commit

Permalink
Merge pull request #2168 from romainbrancourt/fix-apollo-gateway-plugins
Browse files Browse the repository at this point in the history
fix(apollo): add global plugins for apollo gateway driver
  • Loading branch information
kamilmysliwiec committed May 20, 2022
2 parents 90ea2fc + 46998b3 commit 6d77cbd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/apollo/lib/drivers/apollo-gateway.driver.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { Injectable } from '@nestjs/common';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { ModulesContainer } from '@nestjs/core';
import { extend } from '@nestjs/graphql';
import { ApolloGatewayDriverConfig } from '../interfaces';
import { PluginsExplorerService } from '../services/plugins-explorer.service';
import { ApolloBaseDriver } from './apollo-base.driver';

@Injectable()
export class ApolloGatewayDriver extends ApolloBaseDriver<ApolloGatewayDriverConfig> {
private readonly pluginsExplorerService: PluginsExplorerService;

constructor(modulesContainer: ModulesContainer) {
super();
this.pluginsExplorerService = new PluginsExplorerService(modulesContainer);
}

public async start(options: ApolloGatewayDriverConfig): Promise<void> {
options.server.plugins = extend(
options.server.plugins || [],
this.pluginsExplorerService.explore(options),
);

const { ApolloGateway } = loadPackage(
'@apollo/gateway',
'ApolloGateway',
Expand Down

0 comments on commit 6d77cbd

Please sign in to comment.