Skip to content

Commit 423200f

Browse files
committed
[RFC] Environment var to silence warning about invalid names.
This provides an opt-out of a spec compliance naming style for legacy schema
1 parent 9033685 commit 423200f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/utilities/assertValidName.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
const NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
1212
const ERROR_PREFIX_RX = /^Error: /;
1313

14+
// Silences warnings if an environment flag is enabled
15+
const noNameWarning =
16+
Boolean(process && process.env && process.env.GRAPHQL_NO_NAME_WARNING);
17+
1418
// Ensures console warnings are only issued once.
1519
let hasWarnedAboutDunder = false;
1620

@@ -26,7 +30,12 @@ export function assertValidName(
2630
`Must be named. Unexpected name: ${name}.`
2731
);
2832
}
29-
if (!isIntrospection && name.slice(0, 2) === '__' && !hasWarnedAboutDunder) {
33+
if (
34+
!isIntrospection &&
35+
!hasWarnedAboutDunder &&
36+
!noNameWarning &&
37+
name.slice(0, 2) === '__'
38+
) {
3039
hasWarnedAboutDunder = true;
3140
/* eslint-disable no-console */
3241
if (console && console.warn) {

0 commit comments

Comments
 (0)