Skip to content

Commit

Permalink
Merge pull request #30 from BouyguesTelecom/feat/sort-fields
Browse files Browse the repository at this point in the history
🔧 Sort fields alphabetically
  • Loading branch information
arnaud authored Aug 26, 2024
2 parents 653b5ee + 87c54da commit 7657378
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/node_modules/@graphql-mesh/merger-stitching/cjs/index.js b/node_modules/@graphql-mesh/merger-stitching/cjs/index.js
index 381e473..951f14d 100644
--- a/node_modules/@graphql-mesh/merger-stitching/cjs/index.js
+++ b/node_modules/@graphql-mesh/merger-stitching/cjs/index.js
@@ -1,5 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
+function sortKeys(dict) {
+ var sorted = [];
+ for(var key in dict) {
+ sorted[sorted.length] = key;
+ }
+ sorted.sort();
+ var tempDict = {};
+ for(var i = 0; i < sorted.length; i++) {
+ tempDict[sorted[i]] = dict[sorted[i]];
+ }
+ return tempDict;
+}
const stitch_1 = require("@graphql-tools/stitch");
class StitchingMerger {
constructor(options) {
@@ -42,6 +54,12 @@ class StitchingMerger {
},
}),
});
+
+ // Sort fields alphabetically
+ Object.keys(unifiedSchema._typeMap).forEach((type) => {
+ unifiedSchema._typeMap[type]._fields = sortKeys(unifiedSchema._typeMap[type]._fields);
+ });
+
return {
schema: unifiedSchema,
};

0 comments on commit 7657378

Please sign in to comment.