apollo-server-express#Config TypeScript Examples

The following examples show how to use apollo-server-express#Config. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: apolloConfig.ts    From liferay-grow with MIT License 6 votes vote down vote up
public async getApolloConfig(): Promise<Config> {
    const { APP_NAME, NODE_ENV, RUN_PLAYGROUND = true } = process.env;

    const playground = RUN_PLAYGROUND
      ? { title: APP_NAME, workspaceName: NODE_ENV }
      : false;

    const schema = await GraphQLSchema.getSchema();

    const apolloServerConfig: Config = {
      cacheControl: { defaultMaxAge: this.defaultMaxAge },
      context: this.context.bind(this),
      formatError: this.formatError,
      playground,
      schema,
    };

    if (NODE_ENV === 'production') {
      apolloServerConfig.introspection = true;
    }

    logger.debug(`${APP_NAME} environment: ${NODE_ENV}`);

    return apolloServerConfig;
  }