@@ -10,6 +10,7 @@ import {
10
10
UserInputError ,
11
11
} from 'apollo-server-core' ;
12
12
import { GraphQLError , GraphQLFormattedError } from 'graphql' ;
13
+ import { omit } from 'lodash' ;
13
14
import { GqlModuleOptions } from '../interfaces/gql-module-options.interface' ;
14
15
15
16
const defaultOptions : GqlModuleOptions = {
@@ -22,28 +23,34 @@ export function mergeDefaults(
22
23
options : GqlModuleOptions ,
23
24
defaults : GqlModuleOptions = defaultOptions ,
24
25
) : GqlModuleOptions {
25
- if ( options . playground !== undefined ) {
26
- // Preserve backward compatibility
27
- if ( options . playground !== false && process . env . NODE_ENV !== 'production' ) {
28
- const playgroundOptions =
29
- typeof options . playground === 'object' ? options . playground : undefined ;
30
- defaults = {
31
- ...defaults ,
32
- plugins : [
33
- ApolloServerPluginLandingPageGraphQLPlayground (
34
- playgroundOptions ,
35
- ) as PluginDefinition ,
36
- ] ,
37
- } ;
38
- } else if ( process . env . NODE_ENV === 'production' ) {
39
- defaults = {
40
- ...defaults ,
41
- plugins : [ ApolloServerPluginLandingPageDisabled ( ) as PluginDefinition ] ,
42
- } ;
43
- }
26
+ if (
27
+ ( options . playground === undefined &&
28
+ process . env . NODE_ENV !== 'production' ) ||
29
+ options . playground
30
+ ) {
31
+ const playgroundOptions =
32
+ typeof options . playground === 'object' ? options . playground : undefined ;
33
+ defaults = {
34
+ ...defaults ,
35
+ plugins : [
36
+ ApolloServerPluginLandingPageGraphQLPlayground (
37
+ playgroundOptions ,
38
+ ) as PluginDefinition ,
39
+ ] ,
40
+ } ;
41
+ } else if (
42
+ ( options . playground === undefined &&
43
+ process . env . NODE_ENV === 'production' ) ||
44
+ options . playground === false
45
+ ) {
46
+ defaults = {
47
+ ...defaults ,
48
+ plugins : [ ApolloServerPluginLandingPageDisabled ( ) as PluginDefinition ] ,
49
+ } ;
44
50
}
51
+
45
52
const moduleOptions = {
46
- ...defaults ,
53
+ ...omit ( defaults , 'plugins' ) ,
47
54
...options ,
48
55
} ;
49
56
moduleOptions . plugins = ( moduleOptions . plugins || [ ] ) . concat (
0 commit comments