-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#2324) * lazy load unused lambda packages in core * Style adjustments plus changes to account for other PRs with similar motives. The work in #2054 was designed in a way that, irregardless of the environment, the `graphql-upload` package would only be loaded if uploads were enabled. Therefore, the guard which checks `process.env.AWS_EXECUTION_ENV` should no longer be necessary. Additionally, we don't need to prefix our type-only variables with underscores, as that's not a style that we've otherwise adopted. * The work in this was mostly also implemented by #2305, #2304 and #2054, but the remaining subscriptions-transport-ws and unnecessary util.promisify imports are still super worth addressing. So, thank you!
- Loading branch information
Showing
4 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import './polyfills/Object.values'; | ||
import './polyfills/Object.entries'; | ||
|
||
require('util.promisify').shim(); | ||
import runtimeSupportsPromisify from './utils/runtimeSupportsPromisify'; | ||
|
||
if (!runtimeSupportsPromisify) { | ||
require('util.promisify').shim(); | ||
} | ||
|
||
export * from './polyfills/fetch'; | ||
export * from './polyfills/url'; |
24 changes: 24 additions & 0 deletions
24
packages/apollo-server-env/src/utils/runtimeSupportsPromisify.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const runtimeSupportsPromisify = (() => { | ||
if ( | ||
process && | ||
process.release && | ||
process.release.name === 'node' && | ||
process.versions && | ||
typeof process.versions.node === 'string' | ||
) { | ||
const [nodeMajor] = process.versions.node | ||
.split('.', 1) | ||
.map(segment => parseInt(segment, 10)); | ||
|
||
if (nodeMajor >= 8) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
// 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 runtimeSupportsPromisify; |