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 f6a4938 commit 73d8fee
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
9 changes: 0 additions & 9 deletions src/utilities/schemaPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ import {
} from '../type/definition';

import { astFromValue } from '../utilities/astFromValue';
import { isMutationType } from './typeComparators';
import { isQueryType } from './typeComparators';
import { isSubscriptionType } from './typeComparators';

type Options = {|
/**
Expand Down Expand Up @@ -90,13 +87,7 @@ function printFilteredSchema(
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);

return (
Expand Down
50 changes: 1 addition & 49 deletions src/utilities/typeComparators.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,52 +119,4 @@ 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 73d8fee

Please sign in to comment.