Skip to content

Commit 28b7823

Browse files
committed
buildClientSchema: Revert breaking change introduced in #1677
More details here: 183ff32#r32971387
1 parent f289555 commit 28b7823

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,26 @@ function cycleIntrospection(sdlString) {
3838
const serverSchema = buildSchema(sdlString);
3939
const initialIntrospection = introspectionFromSchema(serverSchema);
4040
const clientSchema = buildClientSchema(initialIntrospection);
41+
const secondIntrospection = introspectionFromSchema(clientSchema);
42+
43+
hackToRemoveStandardTypes(secondIntrospection);
44+
hackToRemoveStandardTypes(initialIntrospection);
4145

4246
/**
4347
* If the client then runs the introspection query against the client-side
4448
* schema, it should get a result identical to what was returned by the server
4549
*/
46-
const secondIntrospection = introspectionFromSchema(clientSchema);
4750
expect(secondIntrospection).to.deep.equal(initialIntrospection);
48-
4951
return printSchema(clientSchema);
5052
}
5153

54+
// Temporary hack to remove always presented standard types should be removed in 15.0
55+
function hackToRemoveStandardTypes(introspection) {
56+
(introspection.__schema: any).types = introspection.__schema.types.filter(
57+
({name}) => ['ID', 'Float', 'Int', 'Boolean', 'String'].indexOf(name) === -1,
58+
);
59+
}
60+
5261
describe('Type System: build schema from introspection', () => {
5362
it('builds a simple schema', () => {
5463
const sdl = dedent`
@@ -320,6 +329,9 @@ describe('Type System: build schema from introspection', () => {
320329
const introspection = introspectionFromSchema(schema);
321330
const clientSchema = buildClientSchema(introspection);
322331
const secondIntrospection = introspectionFromSchema(clientSchema);
332+
333+
hackToRemoveStandardTypes(secondIntrospection);
334+
hackToRemoveStandardTypes(introspection);
323335
expect(secondIntrospection).to.deep.equal(introspection);
324336

325337
const clientFoodEnum = clientSchema.getType('Food');

src/utilities/buildClientSchema.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ export function buildClientSchema(
9292
);
9393

9494
for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {
95-
if (typeMap[stdType.name]) {
96-
typeMap[stdType.name] = stdType;
97-
}
95+
typeMap[stdType.name] = stdType;
9896
}
9997

10098
// Get the root Query, Mutation, and Subscription types.

0 commit comments

Comments
 (0)