Skip to content

Commit

Permalink
Handle the document type change from Query to Fragment
Browse files Browse the repository at this point in the history
Reviewed By: voideanvalue

Differential Revision: D51671535

fbshipit-source-id: ffc9111250270ec58bf1e434d64c6f632c459d77
  • Loading branch information
alunyov authored and facebook-github-bot committed Nov 29, 2023
1 parent cf0fb39 commit b379edf
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions compiler/crates/relay-compiler/src/graphql_asts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,42 @@ impl GraphQLAsts {
source_location,
) {
for def in document.definitions {
let name = def.name();
if let Some(def_name) = name {
if !definitions_for_file.iter().any(|def| def.name() == name) {
match def {
ExecutableDefinition::Operation(_) => {
removed_definition_names.push(
ArtifactSourceKey::ExecutableDefinition(
OperationDefinitionName(def_name).into(),
),
)
match def {
ExecutableDefinition::Operation(operation) => {
if !(definitions_for_file.iter().any(|def| {
if let ExecutableDefinition::Operation(op) = def {
op.name == operation.name
} else {
false
}
ExecutableDefinition::Fragment(_) => {
removed_definition_names.push(
ArtifactSourceKey::ExecutableDefinition(
FragmentDefinitionName(def_name).into(),
})) {
if let Some(operation_name) = operation.name {
removed_definition_names
.push(ArtifactSourceKey::ExecutableDefinition(
ExecutableDefinitionName::OperationDefinitionName(
OperationDefinitionName(operation_name.value),
),
)
));
}
}
}
ExecutableDefinition::Fragment(fragment) => {
if !(definitions_for_file.iter().any(|def| {
if let ExecutableDefinition::Fragment(frag) = def {
frag.name == fragment.name
} else {
false
}
})) {
removed_definition_names.push(
ArtifactSourceKey::ExecutableDefinition(
ExecutableDefinitionName::FragmentDefinitionName(
FragmentDefinitionName(fragment.name.value),
),
),
);
}
}
}
}
}
Expand Down

0 comments on commit b379edf

Please sign in to comment.