-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn several PR comments from #8347 into code comments.
- Loading branch information
Showing
4 changed files
with
23 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
// The ordering of these imports is important, because it ensures the temporary | ||
// process.env.NODE_ENV polyfill is defined globally (if necessary) before we | ||
// import { isType } from 'graphql'. The instanceOf function that we really care | ||
// about (the one that uses process.env.NODE_ENV) is not exported from the | ||
// top-level graphql package, but isType uses instanceOf, and is exported. | ||
import { undo } from './process'; | ||
import { isType } from 'graphql'; | ||
|
||
export function applyFixes() { | ||
// Calling isType here just to make sure it won't be tree-shaken away, | ||
// provided applyFixes is called elsewhere. | ||
isType(null); | ||
return undo(); | ||
} |
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,3 +1,12 @@ | ||
export { default as __DEV__ } from "./__DEV__"; | ||
// Just in case the graphql package switches from process.env.NODE_ENV to | ||
// __DEV__, make sure __DEV__ is polyfilled before importing graphql. | ||
import { default as __DEV__ } from "./__DEV__"; | ||
export { __DEV__ } | ||
|
||
// Import graphql/jsutils/instanceOf safely, working around its unchecked usage | ||
// of process.env.NODE_ENV and https://github.com/graphql/graphql-js/pull/2894. | ||
import { applyFixes } from "./graphql"; | ||
|
||
// Synchronously undo the global process.env.NODE_ENV polyfill that we created | ||
// temporarily while importing the offending graphql/jsutils/instanceOf module. | ||
applyFixes(); |
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