Skip to content

Commit d489a35

Browse files
committed
graph: expose skip_duplicates on EntityType and InputSchema APIs
Add TypeInfo::skip_duplicates(), InputSchema::skip_duplicates(), and EntityType::skip_duplicates() following the is_immutable() three-layer delegation pattern. Object types return immutable && skip_duplicates; Interface and Aggregation types return false.
1 parent 6e4c07f commit d489a35

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

graph/src/schema/entity_type.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ impl EntityType {
6868
self.schema.is_immutable(self.atom)
6969
}
7070

71+
pub fn skip_duplicates(&self) -> bool {
72+
self.schema.skip_duplicates(self.atom)
73+
}
74+
7175
pub fn id_type(&self) -> Result<IdType, Error> {
7276
self.schema.id_type(self.atom)
7377
}

graph/src/schema/input/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ impl TypeInfo {
132132
}
133133
}
134134

135+
fn skip_duplicates(&self) -> bool {
136+
match self {
137+
TypeInfo::Object(obj_type) => obj_type.immutable && obj_type.skip_duplicates,
138+
TypeInfo::Interface(_) => false,
139+
TypeInfo::Aggregation(_) => false,
140+
}
141+
}
142+
135143
fn kind(&self) -> TypeKind {
136144
match self {
137145
TypeInfo::Object(_) => TypeKind::Object,
@@ -1212,6 +1220,13 @@ impl InputSchema {
12121220
.unwrap_or(false)
12131221
}
12141222

1223+
pub(in crate::schema) fn skip_duplicates(&self, entity_type: Atom) -> bool {
1224+
self.type_info(entity_type)
1225+
.ok()
1226+
.map(|ti| ti.skip_duplicates())
1227+
.unwrap_or(false)
1228+
}
1229+
12151230
/// Return true if `type_name` is the name of an object or interface type
12161231
pub fn is_reference(&self, type_name: &str) -> bool {
12171232
self.inner

0 commit comments

Comments
 (0)