Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove access to process.env from hot code paths #5657

Merged
merged 7 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/graphqlOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface GraphQLServerOptions<
plugins?: ApolloServerPlugin[];
documentStore?: InMemoryLRUCache<DocumentNode>;
parseOptions?: ParseOptions;
nodeEnv?: string | undefined;
nodeEnv?: string;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah! I made a note to do this, too! Totally missed it.

}

export type DataSources<TContext> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-core/src/runHttpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ export function throwHttpGraphQLError<E extends Error>(
);
}

const NODE_ENV = process.env.NODE_ENV;
const NODE_ENV = process.env.NODE_ENV ?? '';

export async function runHttpQuery(
handlerArguments: Array<any>,
request: HttpQueryRequest,
moberegger marked this conversation as resolved.
Show resolved Hide resolved
): Promise<HttpQueryResponse> {
function debugFromNodeEnv(nodeEnv: string | undefined = NODE_ENV) {
function debugFromNodeEnv(nodeEnv: string = NODE_ENV) {
return nodeEnv !== 'production' && nodeEnv !== 'test';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ export interface Config<ContextFunctionParams = any> extends BaseConfig {
experimental_approximateDocumentStoreMiB?: number;
stopOnTerminationSignals?: boolean;
apollo?: ApolloConfigInput;
nodeEnv?: string | undefined;
nodeEnv?: string;
}