From 0cd475e16c6307904439d8ea48b63df3088c1e41 Mon Sep 17 00:00:00 2001 From: Adrien FIGARD Date: Wed, 4 Sep 2024 17:13:57 +0200 Subject: [PATCH 1/3] :wrench: Sort inputs alphabetically --- .../@graphql-mesh+merger-stitching+0.96.3.patch | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 index a55a65d..6f3f5b4 100644 --- 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 @@ -1,5 +1,5 @@ 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 +index 381e473..0f7ecb2 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 @@ @@ -20,7 +20,7 @@ index 381e473..951f14d 100644 const stitch_1 = require("@graphql-tools/stitch"); class StitchingMerger { constructor(options) { -@@ -42,6 +54,12 @@ class StitchingMerger { +@@ -42,6 +54,24 @@ class StitchingMerger { }, }), }); @@ -29,6 +29,18 @@ index 381e473..951f14d 100644 + Object.keys(unifiedSchema._typeMap).forEach((type) => { + unifiedSchema._typeMap[type]._fields = sortKeys(unifiedSchema._typeMap[type]._fields); + }); ++ // Sort query inputs alphabetically ++ Object.keys(unifiedSchema._typeMap.Query._fields).forEach((field) => { ++ if (unifiedSchema._typeMap.Query._fields[field].args) { ++ unifiedSchema._typeMap.Query._fields[field].args = unifiedSchema._typeMap.Query._fields[field].args.sort((a,b) => a.name.localeCompare(b.name)) ++ } ++ }) ++ // Sort mutation inputs alphabetically ++ Object.keys(unifiedSchema._typeMap.Mutation._fields).forEach((field) => { ++ if (unifiedSchema._typeMap.Mutation._fields[field].args) { ++ unifiedSchema._typeMap.Mutation._fields[field].args = unifiedSchema._typeMap.Mutation._fields[field].args.sort((a,b) => a.name.localeCompare(b.name)) ++ } ++ }) + return { schema: unifiedSchema, From ce53e9a010ac9e63a27eeb8f3cd680dc700a803c Mon Sep 17 00:00:00 2001 From: Adrien FIGARD Date: Tue, 10 Sep 2024 10:19:22 +0200 Subject: [PATCH 2/3] :art: Improve code structure --- ...graphql-mesh+merger-stitching+0.96.3.patch | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) 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 index 6f3f5b4..aa542e1 100644 --- 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 @@ -1,5 +1,5 @@ diff --git a/node_modules/@graphql-mesh/merger-stitching/cjs/index.js b/node_modules/@graphql-mesh/merger-stitching/cjs/index.js -index 381e473..0f7ecb2 100644 +index 381e473..3a4db3d 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 @@ @@ -20,7 +20,7 @@ index 381e473..0f7ecb2 100644 const stitch_1 = require("@graphql-tools/stitch"); class StitchingMerger { constructor(options) { -@@ -42,6 +54,24 @@ class StitchingMerger { +@@ -42,6 +54,21 @@ class StitchingMerger { }, }), }); @@ -29,18 +29,15 @@ index 381e473..0f7ecb2 100644 + Object.keys(unifiedSchema._typeMap).forEach((type) => { + unifiedSchema._typeMap[type]._fields = sortKeys(unifiedSchema._typeMap[type]._fields); + }); -+ // Sort query inputs alphabetically -+ Object.keys(unifiedSchema._typeMap.Query._fields).forEach((field) => { -+ if (unifiedSchema._typeMap.Query._fields[field].args) { -+ unifiedSchema._typeMap.Query._fields[field].args = unifiedSchema._typeMap.Query._fields[field].args.sort((a,b) => a.name.localeCompare(b.name)) -+ } -+ }) -+ // Sort mutation inputs alphabetically -+ Object.keys(unifiedSchema._typeMap.Mutation._fields).forEach((field) => { -+ if (unifiedSchema._typeMap.Mutation._fields[field].args) { -+ unifiedSchema._typeMap.Mutation._fields[field].args = unifiedSchema._typeMap.Mutation._fields[field].args.sort((a,b) => a.name.localeCompare(b.name)) -+ } -+ }) ++ // Sort query and mutation inputs alphabetically ++ ['Query', 'Mutation'].forEach((operation) => { ++ const fields = unifiedSchema._typeMap[operation]._fields; ++ Object.keys(fields).map(field => { ++ if (fields[field].args) { ++ fields[field].args.sort((a, b) => a.name.localeCompare(b.name)); ++ } ++ }); ++ }); + return { schema: unifiedSchema, From 7cb43b336901a43a43bf7d7b8eaf27548e5b21a4 Mon Sep 17 00:00:00 2001 From: Adrien FIGARD Date: Tue, 10 Sep 2024 14:09:47 +0200 Subject: [PATCH 3/3] :art: Improve code structure --- .../@graphql-mesh+merger-stitching+0.96.3.patch | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 index aa542e1..5db70e3 100644 --- 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 @@ -1,5 +1,5 @@ diff --git a/node_modules/@graphql-mesh/merger-stitching/cjs/index.js b/node_modules/@graphql-mesh/merger-stitching/cjs/index.js -index 381e473..3a4db3d 100644 +index 381e473..8b6840d 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 @@ @@ -20,7 +20,7 @@ index 381e473..3a4db3d 100644 const stitch_1 = require("@graphql-tools/stitch"); class StitchingMerger { constructor(options) { -@@ -42,6 +54,21 @@ class StitchingMerger { +@@ -42,6 +54,19 @@ class StitchingMerger { }, }), }); @@ -32,10 +32,8 @@ index 381e473..3a4db3d 100644 + // Sort query and mutation inputs alphabetically + ['Query', 'Mutation'].forEach((operation) => { + const fields = unifiedSchema._typeMap[operation]._fields; -+ Object.keys(fields).map(field => { -+ if (fields[field].args) { -+ fields[field].args.sort((a, b) => a.name.localeCompare(b.name)); -+ } ++ Object.keys(fields).filter((field) => fields[field].args).forEach((field) => { ++ fields[field].args.sort((a, b) => a.name.localeCompare(b.name)); + }); + }); +