Skip to content

Commit

Permalink
Sort resolver artifact output
Browse files Browse the repository at this point in the history
Summary: This diff fixes an issue found in D57033209 where a `Vec` was converted to a `FxHashMap`. This caused the order of the resolvers being processed to be lost. The output of the compiler should be deterministic so I've sorted the results before printing them. It looks like this is a common pattern with other artifacts processed in the file.

Reviewed By: captbaritone

Differential Revision: D57195364

fbshipit-source-id: 62177f43eac188ed4d1d098d48763a3400ad92b9
  • Loading branch information
evanyeung authored and facebook-github-bot committed May 10, 2024
1 parent a7d4b48 commit ca2b861
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions compiler/crates/relay-codegen/src/build_ast.rs
Expand Up @@ -264,12 +264,14 @@ pub fn build_resolvers_schema(
}
}
if !fields.is_empty() {
fields.sort_by_key(|field| field.key);
map.push(ObjectEntry {
key: object.name.item.0,
value: Primitive::Key(ast_builder.intern(Ast::Object(fields))),
})
}
}
map.sort_by_key(|field| field.key);

ast_builder.intern(Ast::Object(map))
}
Expand Down
Expand Up @@ -65,7 +65,7 @@ type User { name: String }
==================================== OUTPUT ===================================
//- __generated__/ResolversSchemaModule.js
/**
* <auto-generated> SignedSource<<8da0a1dd4b3c3a10115920f878c9f044>>
* <auto-generated> SignedSource<<983b85d6af01334176c1f903eecd63de>>
* @flow
* @lightSyntaxTransform
* @nogrep
Expand All @@ -91,14 +91,14 @@ var schema_resolvers/*: SchemaResolvers*/ = {
"resolverFunction": require('User_bar').bar_live,
"rootFragment": null
},
"bar_plural": {
"resolverFunction": require('User_bar').bar_plural,
"rootFragment": null
},
"bar_live_plural": {
"resolverFunction": require('User_bar').bar_live_plural,
"rootFragment": null
},
"bar_plural": {
"resolverFunction": require('User_bar').bar_plural,
"rootFragment": null
},
"foo": {
"resolverFunction": require('User_foo').foo,
"rootFragment": require('UserFooFragment$normalization.graphql')
Expand Down
Expand Up @@ -52,7 +52,7 @@ type User { name: String }
==================================== OUTPUT ===================================
//- __generated__/ResolversSchemaModule.js
/**
* <auto-generated> SignedSource<<8da0a1dd4b3c3a10115920f878c9f044>>
* <auto-generated> SignedSource<<983b85d6af01334176c1f903eecd63de>>
* @flow
* @lightSyntaxTransform
* @nogrep
Expand All @@ -78,14 +78,14 @@ var schema_resolvers/*: SchemaResolvers*/ = {
"resolverFunction": require('User_bar').bar_live,
"rootFragment": null
},
"bar_plural": {
"resolverFunction": require('User_bar').bar_plural,
"rootFragment": null
},
"bar_live_plural": {
"resolverFunction": require('User_bar').bar_live_plural,
"rootFragment": null
},
"bar_plural": {
"resolverFunction": require('User_bar').bar_plural,
"rootFragment": null
},
"foo": {
"resolverFunction": require('User_foo').foo,
"rootFragment": require('UserFooFragment$normalization.graphql')
Expand Down

0 comments on commit ca2b861

Please sign in to comment.