Skip to content

Commit

Permalink
Rejigger ensurePluginInstantiation to accommodate upcoming changes.
Browse files Browse the repository at this point in the history
Inspired by landing some PRs separately and a merge commit that could have
been avoided, but also inspired by the following comment
by @trevor-scheer  whicih made it clear my organization was just a _bit_
off.

Ref: #3991 (comment)
  • Loading branch information
abernix committed Apr 16, 2020
1 parent 0d31d1b commit 4b59b02
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,16 @@ export class ApolloServerBase {
return sdlFieldType.name == 'String';
}

private ensurePluginInstantiation(plugins?: PluginDefinition[]): void {
if (!plugins || !plugins.length) {
return;
}
private ensurePluginInstantiation(plugins: PluginDefinition[] = []): void {
const pluginsToInit: PluginDefinition[] = [];

// Internal plugins should be added to `pluginsToInit` here.
// User's plugins, provided as an argument to this method, will be added
// at the end of that list so they take precidence.
// A follow-up commit will actually introduce this.

this.plugins = plugins.map(plugin => {
pluginsToInit.push(...plugins);
this.plugins = pluginsToInit.map(plugin => {
if (typeof plugin === 'function') {
return plugin();
}
Expand Down

0 comments on commit 4b59b02

Please sign in to comment.