mirror of
https://github.com/vale981/apollo-server
synced 2025-03-05 09:41:40 -05:00
More strict check for node version for graphql-upload
(#2235)
Stop traversing the `graphql-upload` module tree in all non-Node.js environments, to support subset-V8 runtimes like Fly.io.
This commit is contained in:
parent
25028e3678
commit
cd674aae72
5 changed files with 15 additions and 10 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
### vNEXT
|
||||
|
||||
- Avoid traversing `graphql-uploads` module tree in run-time environments which aren't Node.js. [PR #2235](https://github.com/apollographql/apollo-server/pull/2235)
|
||||
|
||||
### v2.3.2
|
||||
|
||||
- Switch from `json-stable-stringify` to `fast-json-stable-stringify`. [PR #2065](https://github.com/apollographql/apollo-server/pull/2065)
|
||||
|
|
|
@ -14,7 +14,7 @@ import { GraphQLExtension } from 'graphql-extensions';
|
|||
import { EngineReportingAgent } from 'apollo-engine-reporting';
|
||||
import { InMemoryLRUCache } from 'apollo-server-caching';
|
||||
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
|
||||
import supportsUploadsInNode from './utils/supportsUploadsInNode';
|
||||
import runtimeSupportsUploads from './utils/runtimeSupportsUploads';
|
||||
|
||||
import {
|
||||
SubscriptionServer,
|
||||
|
@ -90,7 +90,7 @@ function getEngineServiceId(engine: Config['engine']): string | undefined {
|
|||
}
|
||||
|
||||
const forbidUploadsForTesting =
|
||||
process && process.env.NODE_ENV === 'test' && !supportsUploadsInNode;
|
||||
process && process.env.NODE_ENV === 'test' && !runtimeSupportsUploads;
|
||||
|
||||
export class ApolloServerBase {
|
||||
public subscriptionsPath?: string;
|
||||
|
@ -205,7 +205,7 @@ export class ApolloServerBase {
|
|||
|
||||
if (uploads !== false && !forbidUploadsForTesting) {
|
||||
if (this.supportsUploads()) {
|
||||
if (!supportsUploadsInNode) {
|
||||
if (!runtimeSupportsUploads) {
|
||||
printNodeFileUploadsMessage();
|
||||
throw new Error(
|
||||
'`graphql-upload` is no longer supported on Node.js < v8.5.0. ' +
|
||||
|
|
|
@ -41,7 +41,7 @@ export const gql: (
|
|||
...substitutions: any[]
|
||||
) => DocumentNode = gqlTag;
|
||||
|
||||
import supportsUploadsInNode from './utils/supportsUploadsInNode';
|
||||
import runtimeSupportsUploads from './utils/runtimeSupportsUploads';
|
||||
import { GraphQLScalarType } from 'graphql';
|
||||
export { default as processFileUploads } from './processFileUploads';
|
||||
|
||||
|
@ -53,6 +53,6 @@ export { default as processFileUploads } from './processFileUploads';
|
|||
// experimental ECMAScript modules), this conditional export is necessary
|
||||
// to avoid modern ECMAScript from failing to parse by versions of Node.js
|
||||
// which don't support it (yet — eg. Node.js 6 and async/await).
|
||||
export const GraphQLUpload = supportsUploadsInNode
|
||||
export const GraphQLUpload = runtimeSupportsUploads
|
||||
? (require('graphql-upload').GraphQLUpload as GraphQLScalarType)
|
||||
: undefined;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path="./types/graphql-upload.d.ts" />
|
||||
|
||||
import supportsUploadsInNode from './utils/supportsUploadsInNode';
|
||||
import runtimeSupportsUploads from './utils/runtimeSupportsUploads';
|
||||
|
||||
// We'll memoize this function once at module load time since it should never
|
||||
// change during runtime. In the event that we're using a version of Node.js
|
||||
|
@ -8,7 +8,7 @@ import supportsUploadsInNode from './utils/supportsUploadsInNode';
|
|||
const processFileUploads:
|
||||
| typeof import('graphql-upload').processRequest
|
||||
| undefined = (() => {
|
||||
if (supportsUploadsInNode) {
|
||||
if (runtimeSupportsUploads) {
|
||||
return require('graphql-upload')
|
||||
.processRequest as typeof import('graphql-upload').processRequest;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const supportsUploadsInNode = (() => {
|
||||
const runtimeSupportsUploads = (() => {
|
||||
if (
|
||||
process &&
|
||||
process.release &&
|
||||
|
@ -13,9 +13,12 @@ const supportsUploadsInNode = (() => {
|
|||
if (nodeMajor < 8 || (nodeMajor === 8 && nodeMinor < 5)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// If we haven't matched any of the above criteria, we'll remain unsupported
|
||||
// for this mysterious environment until a pull-request proves us otherwise.
|
||||
return false;
|
||||
})();
|
||||
|
||||
export default supportsUploadsInNode;
|
||||
export default runtimeSupportsUploads;
|
Loading…
Add table
Reference in a new issue