Skip to content

Commit

Permalink
BREAKING: remove sorting by name from printSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed Jan 23, 2020
1 parent bf39198 commit 0912c06
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 57 deletions.
10 changes: 1 addition & 9 deletions src/utilities/schemaPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,7 @@ function printFilteredSchema(
): string {
const directives = schema.getDirectives().filter(directiveFilter);
const typeMap = schema.getTypeMap();
const types = objectValues(typeMap)
.sort((type1, type2) => {
if (isMutationType(schema, type1)) return -1;
if (isQueryType(schema, type1)) return -1;
if (isSubscriptionType(schema, type1)) return -1;

return type1.name.localeCompare(type2.name);
})
.filter(typeFilter);
const types = objectValues(typeMap).filter(typeFilter);

return (
[printSchemaDefinition(schema)]
Expand Down
48 changes: 0 additions & 48 deletions src/utilities/typeComparators.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,51 +120,3 @@ export function doTypesOverlap(
// Otherwise the types do not overlap.
return false;
}

/**
* Checks if type is query
*
* @internal
*/
export function isQueryType(schema: GraphQLSchema, type: GraphQLCompositeType) {
const schemaType = schema.getQueryType();
if (schemaType) {
return schemaType.name === type.name;
}

return false;
}

/**
* Checks if type is mutation
*
* @internal
*/
export function isMutationType(
schema: GraphQLSchema,
type: GraphQLCompositeType,
) {
const schemaType = schema.getMutationType();
if (schemaType) {
return schemaType.name === type.name;
}

return false;
}

/**
* Checks if type is subscription
*
* @internal
*/
export function isSubscriptionType(
schema: GraphQLSchema,
type: GraphQLCompositeType,
) {
const schemaType = schema.getSubscriptionType();
if (schemaType) {
return schemaType.name === type.name;
}

return false;
}

0 comments on commit 0912c06

Please sign in to comment.