Skip to content

buildClientSchema: Revert breaking change introduced in #1677 #1808

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
Mar 31, 2019
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
17 changes: 15 additions & 2 deletions src/utilities/__tests__/buildClientSchema-test.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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