Skip to content

Remove special case in assertValidName #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/utilities/__tests__/assertValidName-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,4 @@ describe('assertValidName()', () => {
it('throws for names with invalid characters', () => {
expect(() => assertValidName('>--()-->')).to.throw(/Names must match/);
});

it('does not throw for legacy servers that use __configs__ introspection', () => {
expect(() => assertValidName('__configs__')).not.to.throw();
});
});
10 changes: 1 addition & 9 deletions src/utilities/assertValidName.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ export function isValidNameError(
node?: ASTNode | void,
): GraphQLError | void {
invariant(typeof name === 'string', 'Expected string');
if (
name.length > 1 &&
name[0] === '_' &&
name[1] === '_' &&
// Note: this special case is not part of the spec and exists only to
// support legacy server configurations. Do not rely on this special case
// as it may be removed at any time.
name !== '__configs__'
) {
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
return new GraphQLError(
`Name "${name}" must not begin with "__", which is reserved by ` +
'GraphQL introspection.',
Expand Down