From 4866c5dfcea0ba0704e69256fee4aac88962c1e0 Mon Sep 17 00:00:00 2001 From: Adrien FIGARD Date: Mon, 5 Aug 2024 14:16:15 +0200 Subject: [PATCH 1/2] :wrench: Sort fields alphabetically --- .../patches/@graphql-tools+stitch+9.0.3.patch | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch b/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch index a250573..5e7361c 100644 --- a/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch +++ b/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch @@ -1,3 +1,53 @@ +diff --git a/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js b/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js +index 819b2b6..006424f 100644 +--- a/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js ++++ b/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js +@@ -5,6 +5,18 @@ const graphql_1 = require("graphql"); + const delegate_1 = require("@graphql-tools/delegate"); + const merge_1 = require("@graphql-tools/merge"); + const mergeValidations_js_1 = require("./mergeValidations.js"); ++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; ++} + function mergeCandidates(typeName, candidates, typeMergingOptions) { + const initialCandidateType = candidates[0].type; + if (candidates.some(candidate => candidate.type.constructor !== initialCandidateType.constructor)) { +@@ -37,7 +49,7 @@ exports.mergeCandidates = mergeCandidates; + function mergeObjectTypeCandidates(typeName, candidates, typeMergingOptions) { + candidates = orderedTypeCandidates(candidates, typeMergingOptions); + const description = mergeTypeDescriptions(candidates, typeMergingOptions); +- const fields = fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); ++ const fields = sortKeys(fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); + const typeConfigs = candidates.map(candidate => candidate.type.toConfig()); + const interfaceMap = typeConfigs + .map(typeConfig => typeConfig.interfaces) +@@ -79,7 +91,7 @@ function mergeObjectTypeCandidates(typeName, candidates, typeMergingOptions) { + function mergeInputObjectTypeCandidates(typeName, candidates, typeMergingOptions) { + candidates = orderedTypeCandidates(candidates, typeMergingOptions); + const description = mergeTypeDescriptions(candidates, typeMergingOptions); +- const fields = inputFieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); ++ const fields = sortKeys(inputFieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); + const astNodes = pluck('astNode', candidates); + const fieldAstNodes = canonicalFieldNamesForType(candidates) + .map(fieldName => fields[fieldName]?.astNode) +@@ -113,7 +125,7 @@ function pluck(typeProperty, candidates) { + function mergeInterfaceTypeCandidates(typeName, candidates, typeMergingOptions) { + candidates = orderedTypeCandidates(candidates, typeMergingOptions); + const description = mergeTypeDescriptions(candidates, typeMergingOptions); +- const fields = fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); ++ const fields = sortKeys(fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); + const typeConfigs = candidates.map(candidate => candidate.type.toConfig()); + const interfaceMap = typeConfigs + .map(typeConfig => ('interfaces' in typeConfig ? typeConfig.interfaces : [])) diff --git a/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js b/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js index 5e752ad..3b487f5 100644 --- a/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js From 87c54da55e11f9172d619eaa3f7f9f48d0112a6b Mon Sep 17 00:00:00 2001 From: Adrien FIGARD Date: Fri, 23 Aug 2024 15:32:58 +0200 Subject: [PATCH 2/2] :wrench: Sort fields alphabetically --- ...graphql-mesh+merger-stitching+0.96.3.patch | 35 +++++++++++++ .../patches/@graphql-tools+stitch+9.0.3.patch | 50 ------------------- 2 files changed, 35 insertions(+), 50 deletions(-) create mode 100644 packages/graphql-mesh/patches/@graphql-mesh+merger-stitching+0.96.3.patch diff --git a/packages/graphql-mesh/patches/@graphql-mesh+merger-stitching+0.96.3.patch b/packages/graphql-mesh/patches/@graphql-mesh+merger-stitching+0.96.3.patch new file mode 100644 index 0000000..a55a65d --- /dev/null +++ b/packages/graphql-mesh/patches/@graphql-mesh+merger-stitching+0.96.3.patch @@ -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, + }; diff --git a/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch b/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch index 5e7361c..a250573 100644 --- a/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch +++ b/packages/graphql-mesh/patches/@graphql-tools+stitch+9.0.3.patch @@ -1,53 +1,3 @@ -diff --git a/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js b/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js -index 819b2b6..006424f 100644 ---- a/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js -+++ b/node_modules/@graphql-tools/stitch/cjs/mergeCandidates.js -@@ -5,6 +5,18 @@ const graphql_1 = require("graphql"); - const delegate_1 = require("@graphql-tools/delegate"); - const merge_1 = require("@graphql-tools/merge"); - const mergeValidations_js_1 = require("./mergeValidations.js"); -+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; -+} - function mergeCandidates(typeName, candidates, typeMergingOptions) { - const initialCandidateType = candidates[0].type; - if (candidates.some(candidate => candidate.type.constructor !== initialCandidateType.constructor)) { -@@ -37,7 +49,7 @@ exports.mergeCandidates = mergeCandidates; - function mergeObjectTypeCandidates(typeName, candidates, typeMergingOptions) { - candidates = orderedTypeCandidates(candidates, typeMergingOptions); - const description = mergeTypeDescriptions(candidates, typeMergingOptions); -- const fields = fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); -+ const fields = sortKeys(fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); - const typeConfigs = candidates.map(candidate => candidate.type.toConfig()); - const interfaceMap = typeConfigs - .map(typeConfig => typeConfig.interfaces) -@@ -79,7 +91,7 @@ function mergeObjectTypeCandidates(typeName, candidates, typeMergingOptions) { - function mergeInputObjectTypeCandidates(typeName, candidates, typeMergingOptions) { - candidates = orderedTypeCandidates(candidates, typeMergingOptions); - const description = mergeTypeDescriptions(candidates, typeMergingOptions); -- const fields = inputFieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); -+ const fields = sortKeys(inputFieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); - const astNodes = pluck('astNode', candidates); - const fieldAstNodes = canonicalFieldNamesForType(candidates) - .map(fieldName => fields[fieldName]?.astNode) -@@ -113,7 +125,7 @@ function pluck(typeProperty, candidates) { - function mergeInterfaceTypeCandidates(typeName, candidates, typeMergingOptions) { - candidates = orderedTypeCandidates(candidates, typeMergingOptions); - const description = mergeTypeDescriptions(candidates, typeMergingOptions); -- const fields = fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions); -+ const fields = sortKeys(fieldConfigMapFromTypeCandidates(candidates, typeMergingOptions)); - const typeConfigs = candidates.map(candidate => candidate.type.toConfig()); - const interfaceMap = typeConfigs - .map(typeConfig => ('interfaces' in typeConfig ? typeConfig.interfaces : [])) diff --git a/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js b/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js index 5e752ad..3b487f5 100644 --- a/node_modules/@graphql-tools/stitch/cjs/mergeValidations.js