Skip to content

Commit

Permalink
Add correct root fragment information
Browse files Browse the repository at this point in the history
Summary: I noticed when comparing the IR output in our tests, that the root fragment information for the Flow based schema generation was incorrect compared to the docblock based schema gen. This diff updates them so they are using the same information. This is important for the location of error messages.

Reviewed By: captbaritone

Differential Revision: D58709712

fbshipit-source-id: 457a1ced4f101660b2a0fa7cef3aa3c56fac4d48
  • Loading branch information
evanyeung authored and facebook-github-bot committed Jun 18, 2024
1 parent 230f8c5 commit bb6f7b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion compiler/crates/relay-schema-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,18 @@ impl RelayResolverExtractor {
fragment_definition.type_condition.span,
fragment_definition.type_condition.type_.value,
);
let root_fragment = Some(WithLocation::from_span(
fragment_definition.location.source_location(),
fragment_definition.name.span,
FragmentDefinitionName(fragment_definition.name.value),
));
let live = field
.is_live
.map(|loc| UnpopulatedIrField { key_location: loc });
self.resolved_field_definitions.push(TerseRelayResolverIr {
field: field_definition,
type_: fragment_type_condition,
root_fragment: Some(field.entity_name.map(FragmentDefinitionName)), // this includes the $key
root_fragment,
location: field.field_name.location,
deprecated: None,
live,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ Field(
},
root_fragment: Some(
WithLocation {
location: module.js:544:567,
location: module.js:14:33,
item: FragmentDefinitionName(
"CatIsHungryFragment$key",
"CatIsHungryFragment",
),
},
),
Expand All @@ -98,7 +98,7 @@ Field(
),
)
extend type Cat {
full_name: String! @relay_resolver(has_output_type: true, import_name: "full_name", import_path: "module.js", fragment_name: "CatIsHungryFragment$key") @resolver_source_hash(value: "97c71c89ad8ccb1e0ff10de8887a25e0")
full_name: String! @relay_resolver(fragment_name: "CatIsHungryFragment", has_output_type: true, import_name: "full_name", import_path: "module.js") @resolver_source_hash(value: "97c71c89ad8ccb1e0ff10de8887a25e0")
}


Expand Down

0 comments on commit bb6f7b3

Please sign in to comment.