From 2e449af8f642c150fa171bc4147a3d3a687bed34 Mon Sep 17 00:00:00 2001 From: Robert Balicki Date: Thu, 16 Feb 2023 12:51:38 -0800 Subject: [PATCH] Sort CustomScalarImports Summary: * `meerkat` was emitting a custom scalar import out of order. This will hopefully fix it! * We've seen instances of `CustomScalarImport`'s being emitted in different orders, though using the same source file. Sorting the `CustomScalarImport` before printing it might remove this inconsistent behavior. * In particular, there is an instance of a custom scalar that is currently in reverse-alphabetical order in the checked-in generated artifact; this artifact is the one gets generated inconsistently. This diff changes that generated artifact, increasing my confidence that this will help. Reviewed By: kassens Differential Revision: D43368527 fbshipit-source-id: 500715406a141363f1c9a7b4243605fbe239ebb2 --- compiler/crates/relay-typegen/src/write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/crates/relay-typegen/src/write.rs b/compiler/crates/relay-typegen/src/write.rs index 8e0b32c418cf9..07791d08fb41c 100644 --- a/compiler/crates/relay-typegen/src/write.rs +++ b/compiler/crates/relay-typegen/src/write.rs @@ -962,7 +962,7 @@ fn write_custom_scalar_imports( custom_scalars: CustomScalarsImports, writer: &mut Box, ) -> FmtResult { - for (name, path) in custom_scalars.iter() { + for (name, path) in custom_scalars.iter().sorted_by_key(|(key, _)| *key) { writer.write_import_type(&[name.lookup()], path.to_str().unwrap())? }