Skip to content

Commit

Permalink
buildClientSchema: Revert breaking change introduced in #1677 (#1808)
Browse files Browse the repository at this point in the history
More details here: 183ff32#r32971387
  • Loading branch information
IvanGoncharov committed Mar 31, 2019
1 parent f289555 commit 3c79bed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/utilities/__tests__/buildClientSchema-test.js
Expand Up @@ -38,17 +38,27 @@ function cycleIntrospection(sdlString) {
const serverSchema = buildSchema(sdlString);
const initialIntrospection = introspectionFromSchema(serverSchema);
const clientSchema = buildClientSchema(initialIntrospection);
const secondIntrospection = introspectionFromSchema(clientSchema);

hackToRemoveStandardTypes(secondIntrospection);
hackToRemoveStandardTypes(initialIntrospection);

/**
* If the client then runs the introspection query against the client-side
* schema, it should get a result identical to what was returned by the server
*/
const secondIntrospection = introspectionFromSchema(clientSchema);
expect(secondIntrospection).to.deep.equal(initialIntrospection);

return printSchema(clientSchema);
}

// Temporary hack to remove always presented standard types should be removed in 15.0
function hackToRemoveStandardTypes(introspection) {
(introspection.__schema: any).types = introspection.__schema.types.filter(
({ name }) =>
['ID', 'Float', 'Int', 'Boolean', 'String'].indexOf(name) === -1,
);
}

describe('Type System: build schema from introspection', () => {
it('builds a simple schema', () => {
const sdl = dedent`
Expand Down Expand Up @@ -320,6 +330,9 @@ describe('Type System: build schema from introspection', () => {
const introspection = introspectionFromSchema(schema);
const clientSchema = buildClientSchema(introspection);
const secondIntrospection = introspectionFromSchema(clientSchema);

hackToRemoveStandardTypes(secondIntrospection);
hackToRemoveStandardTypes(introspection);
expect(secondIntrospection).to.deep.equal(introspection);

const clientFoodEnum = clientSchema.getType('Food');
Expand Down
4 changes: 1 addition & 3 deletions src/utilities/buildClientSchema.js
Expand Up @@ -92,9 +92,7 @@ export function buildClientSchema(
);

for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {
if (typeMap[stdType.name]) {
typeMap[stdType.name] = stdType;
}
typeMap[stdType.name] = stdType;
}

// Get the root Query, Mutation, and Subscription types.
Expand Down

0 comments on commit 3c79bed

Please sign in to comment.