diff --git a/index.js b/index.js index c961b59..7ae6be3 100644 --- a/index.js +++ b/index.js @@ -5,16 +5,22 @@ import {readFileSync} from 'fs'; import {resolvers} from './resolvers.js'; const typeDefs = gql(readFileSync('./schema.graphql', 'utf-8')); +const schema = buildSubgraphSchema({typeDefs, resolvers}); -const server = new ApolloServer({ - schema: buildSubgraphSchema({typeDefs, resolvers}), - introspection: true, - plugins: [ +let plugins; +if (process.env.NODE_ENV === 'production') { + plugins = [ ApolloServerPluginLandingPageProductionDefault({ footer: false, graphRef: process.env.APOLLO_GRAPH_REF }) - ] + ]; +} + +const server = new ApolloServer({ + schema, + introspection: true, + plugins }); server.listen({port: process.env.PORT || 4000}).then(({url}) => {