Skip to content

Commit

Permalink
Don't enable uploads when using an unsupported Node.js in tests.
Browse files Browse the repository at this point in the history
Now that there are specific versions of Node.js which don't support file
uploads (namely, <= 8.5.0) we need to explicitly disable uploads on those
versions, similar to how those users must opt-in to that behavior by setting
`uploads: false` in their Apollo Server constructor options.

This effectively accomplishes exactly that, but only when necessary.
  • Loading branch information
abernix committed Nov 30, 2018
1 parent 7e6d6cf commit 2fd56f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ function getEngineServiceId(engine: Config['engine']): string | undefined {
return;
}

const forbidUploadsForTesting =
process && process.env.NODE_ENV === 'test' && !supportsUploadsInNode;

export class ApolloServerBase {
public subscriptionsPath?: string;
public graphqlPath: string = '/graphql';
Expand Down Expand Up @@ -200,7 +203,7 @@ export class ApolloServerBase {
this.requestOptions = requestOptions as GraphQLOptions;
this.context = context;

if (uploads !== false) {
if (uploads !== false && !forbidUploadsForTesting) {
if (this.supportsUploads()) {
if (!supportsUploadsInNode) {
printNodeFileUploadsMessage();
Expand Down

0 comments on commit 2fd56f0

Please sign in to comment.