Skip to content

Commit 0071110

Browse files
authored
Add special case for legacy servers. (#1162)
Much older versions of GraphQL use `__configs__` as part of a pseudo-introspection meta programming layer. While this is technically against the spec, this adds temporary support.
1 parent 0d66e29 commit 0071110

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/utilities/__tests__/assertValidName-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ describe('assertValidName()', () => {
2323
it('throws for names with invalid characters', () => {
2424
expect(() => assertValidName('>--()-->')).to.throw(/Names must match/);
2525
});
26+
27+
it('does not throw for legacy servers that use __configs__ introspection', () => {
28+
expect(() => assertValidName('__configs__')).not.to.throw();
29+
});
2630
});

src/utilities/assertValidName.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ export function isValidNameError(
3232
node?: ASTNode | void,
3333
): GraphQLError | void {
3434
invariant(typeof name === 'string', 'Expected string');
35-
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
35+
if (
36+
name.length > 1 &&
37+
name[0] === '_' &&
38+
name[1] === '_' &&
39+
// Note: this special case is not part of the spec and exists only to
40+
// support legacy server configurations. Do not rely on this special case
41+
// as it may be removed at any time.
42+
name !== '__configs__'
43+
) {
3644
return new GraphQLError(
3745
`Name "${name}" must not begin with "__", which is reserved by ` +
3846
'GraphQL introspection.',

0 commit comments

Comments
 (0)