Skip to content

Commit

Permalink
fix: map over services only if they are actually provided
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Apr 21, 2020
1 parent 4a2014b commit 72e6424
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/http-handler-apollo-gateway/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { HttpHandlerApolloGatewayOptions } from "./types";
import gatewayHandler from "./gatewayHandler";
import errorHandler from "./errorHandler";
import { Plugin } from "@webiny/plugins/types";

export default (options: HttpHandlerApolloGatewayOptions) => [
gatewayHandler(options),
errorHandler(),
options.services.map(service => ({
type: "http-handler-apollo-gateway-service",
name: "http-handler-apollo-gateway-service-" + service.name,
service
}))
];
export default (options: HttpHandlerApolloGatewayOptions) => {
const plugins = [gatewayHandler(options), errorHandler()] as Plugin[];

if (Array.isArray(options.services)) {
plugins.push(
...options.services.map(service => ({
type: "http-handler-apollo-gateway-service",
name: "http-handler-apollo-gateway-service-" + service.name,
service
}))
);
}

return plugins;
};

0 comments on commit 72e6424

Please sign in to comment.