Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Allow for filter combinations with logical ops
Browse files Browse the repository at this point in the history
  • Loading branch information
deekerno committed Dec 13, 2023
1 parent a2941aa commit ae34b45
Showing 1 changed file with 80 additions and 1 deletion.
81 changes: 80 additions & 1 deletion packages/fuel-indexer-lib/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ fn create_filter_input_obj_for_entity(
return None;
}

let input_val_defs = searchable_fields
let mut input_val_defs = searchable_fields
.into_iter()
.map(|f| {
Positioned::new(
Expand Down Expand Up @@ -757,6 +757,85 @@ fn create_filter_input_obj_for_entity(
})
.collect::<Vec<Positioned<InputValueDefinition>>>();

// Allow for combinations of filters
input_val_defs.push(Positioned::new(
InputValueDefinition {
description: None,
name: Positioned::new(Name::new("and"), dummy_position),
ty: Positioned::new(
Type {
base: BaseType::Named(Name::new(format!(
"{}FilterInput",
entity_name
))),
nullable: true,
},
dummy_position,
),
default_value: None,
directives: vec![Positioned::new(
ConstDirective {
name: Positioned::new(Name::new("internal"), dummy_position),
arguments: vec![],
},
dummy_position,
)],
},
dummy_position,
));

input_val_defs.push(Positioned::new(
InputValueDefinition {
description: None,
name: Positioned::new(Name::new("or"), dummy_position),
ty: Positioned::new(
Type {
base: BaseType::Named(Name::new(format!(
"{}FilterInput",
entity_name
))),
nullable: true,
},
dummy_position,
),
default_value: None,
directives: vec![Positioned::new(
ConstDirective {
name: Positioned::new(Name::new("internal"), dummy_position),
arguments: vec![],
},
dummy_position,
)],
},
dummy_position,
));

input_val_defs.push(Positioned::new(
InputValueDefinition {
description: None,
name: Positioned::new(Name::new("not"), dummy_position),
ty: Positioned::new(
Type {
base: BaseType::Named(Name::new(format!(
"{}FilterInput",
entity_name
))),
nullable: true,
},
dummy_position,
),
default_value: None,
directives: vec![Positioned::new(
ConstDirective {
name: Positioned::new(Name::new("internal"), dummy_position),
arguments: vec![],
},
dummy_position,
)],
},
dummy_position,
));

let filter_input_obj = InputObjectType {
fields: input_val_defs,
};
Expand Down

0 comments on commit ae34b45

Please sign in to comment.