Skip to content

Commit bb9c68c

Browse files
committed
Allow legacy names in client schemas.
1 parent 8f936da commit bb9c68c

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,34 @@ describe('Type System: build schema from introspection', () => {
669669
expect(secondIntrospection.data).to.containSubset(newIntrospection);
670670
});
671671

672+
it('builds a schema with legacy names', () => {
673+
const introspection = {
674+
__schema: {
675+
queryType: {
676+
name: 'Query',
677+
},
678+
types: [
679+
{
680+
name: 'Query',
681+
kind: 'OBJECT',
682+
fields: [
683+
{
684+
name: '__badName',
685+
args: [],
686+
type: { name: 'String' },
687+
},
688+
],
689+
interfaces: [],
690+
},
691+
],
692+
},
693+
};
694+
const schema = buildClientSchema(introspection, {
695+
allowedLegacyNames: ['__badName'],
696+
});
697+
expect(schema.__allowedLegacyNames).to.deep.equal(['__badName']);
698+
});
699+
672700
it('builds a schema aware of deprecation', async () => {
673701
const schema = new GraphQLSchema({
674702
query: new GraphQLObjectType({

src/utilities/buildClientSchema.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,10 @@ import type {
6060
IntrospectionNamedTypeRef,
6161
} from './introspectionQuery';
6262

63+
import type { GraphQLSchemaValidationOptions } from '../type/schema';
64+
6365
type Options = {|
64-
/**
65-
* When building a schema from a GraphQL service's introspection result, it
66-
* might be safe to assume the schema is valid. Set to true to assume the
67-
* produced schema is valid.
68-
*
69-
* Default: false
70-
*/
71-
assumeValid?: boolean,
66+
...GraphQLSchemaValidationOptions,
7267
|};
7368

7469
/**
@@ -414,5 +409,6 @@ export function buildClientSchema(
414409
types,
415410
directives,
416411
assumeValid: options && options.assumeValid,
412+
allowedLegacyNames: options && options.allowedLegacyNames,
417413
});
418414
}

0 commit comments

Comments
 (0)