Skip to content

Commit e5c05d6

Browse files
committed
graph: parse skipDuplicates from @entity directive
Add kw::SKIP_DUPLICATES constant, skip_duplicates bool field to ObjectType, and parsing logic in ObjectType::new() defaulting to false when absent.
1 parent a7482d6 commit e5c05d6

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

graph/src/schema/input/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub mod kw {
4242
pub const ENTITY: &str = "entity";
4343
pub const IMMUTABLE: &str = "immutable";
4444
pub const TIMESERIES: &str = "timeseries";
45+
pub const SKIP_DUPLICATES: &str = "skipDuplicates";
4546
pub const TIMESTAMP: &str = "timestamp";
4647
pub const AGGREGATE: &str = "aggregate";
4748
pub const AGGREGATION: &str = "aggregation";
@@ -414,6 +415,7 @@ pub struct ObjectType {
414415
/// is part of an aggregation
415416
aggregation: Option<Atom>,
416417
pub timeseries: bool,
418+
pub skip_duplicates: bool,
417419
interfaces: Box<[Word]>,
418420
shared_interfaces: Box<[Atom]>,
419421
}
@@ -453,13 +455,18 @@ impl ObjectType {
453455
None => timeseries,
454456
_ => unreachable!("validations ensure we don't get here"),
455457
};
458+
let skip_duplicates = match dir.argument(kw::SKIP_DUPLICATES) {
459+
Some(Value::Boolean(sd)) => *sd,
460+
_ => false,
461+
};
456462
Self {
457463
name,
458464
fields,
459465
id_type,
460466
immutable,
461467
aggregation: None,
462468
timeseries,
469+
skip_duplicates,
463470
interfaces,
464471
shared_interfaces,
465472
}
@@ -491,6 +498,7 @@ impl ObjectType {
491498
immutable: false,
492499
aggregation: None,
493500
timeseries: false,
501+
skip_duplicates: false,
494502
fields,
495503
shared_interfaces: Box::new([]),
496504
}
@@ -889,6 +897,7 @@ impl Aggregation {
889897
immutable: true,
890898
aggregation: Some(name),
891899
timeseries: false,
900+
skip_duplicates: false,
892901
interfaces: Box::new([]),
893902
shared_interfaces: Box::new([]),
894903
}

0 commit comments

Comments
 (0)