Skip to content

Commit 8d71011

Browse files
authored
chore(deps): update graphql version used in tests (#188)
- Update `graphql` to `15.8.0` - Replace custom schema sorting helper with `lexicographicSortSchema` from `graphql/utilities` - Update test snapshots to match the order produced by `lexicographicSortSchema`
1 parent f157f06 commit 8d71011

16 files changed

+4973
-5631
lines changed

__tests__/helpers.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as pg from "pg";
22
import { parse, buildASTSchema, GraphQLSchema } from "graphql";
3-
import { printSchema } from "graphql/utilities";
3+
import { lexicographicSortSchema, printSchema } from "graphql/utilities";
44

55
export async function withPgPool<T>(
66
cb: (pool: pg.Pool) => Promise<T>
@@ -46,33 +46,5 @@ export function printSchemaOrdered(originalSchema: GraphQLSchema): string {
4646
// Clone schema so we don't damage anything
4747
const schema = buildASTSchema(parse(printSchema(originalSchema)));
4848

49-
const typeMap = schema.getTypeMap();
50-
Object.keys(typeMap).forEach((name) => {
51-
const gqlType = typeMap[name];
52-
53-
// Object?
54-
if ("getFields" in gqlType) {
55-
const fields = gqlType.getFields();
56-
const keys = Object.keys(fields).sort();
57-
keys.forEach((key) => {
58-
const value = fields[key];
59-
60-
// Move the key to the end of the object
61-
delete fields[key];
62-
fields[key] = value;
63-
64-
// Sort args
65-
if ("args" in value) {
66-
value.args.sort((a, b) => a.name.localeCompare(b.name));
67-
}
68-
});
69-
}
70-
71-
// Enum?
72-
if ("getValues" in gqlType) {
73-
gqlType.getValues().sort((a, b) => a.name.localeCompare(b.name));
74-
}
75-
});
76-
77-
return printSchema(schema);
49+
return printSchema(lexicographicSortSchema(schema));
7850
}

0 commit comments

Comments
 (0)