Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Seanaye/feat/hoist edge composition (#4747)
Sean Aye8464e9885c97
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.jsonindex a2544c1e94..5be151647e 100644--- a/.github/workspace-dep-closures.json+++ b/.github/workspace-dep-closures.json@@ -2600,19 +2600,26 @@],"graphql_common": ["crates/cowlike",+ "crates/document_sub_type","crates/filter_ast","crates/graphql_common",+ "crates/item_filters","crates/macro_user_id","crates/model-entity",+ "crates/model_file_type",+ "crates/models_properties",+ "crates/non_empty","crates/workspace-hack"],"graphql_notification": ["crates/ai_toolset","crates/cowlike","crates/decode_jwt",+ "crates/document_sub_type","crates/filter_ast","crates/graphql_common","crates/graphql_notification",+ "crates/item_filters","crates/last_online_tracker","crates/macro_auth","crates/macro_env",@@ -2622,8 +2629,11 @@"crates/macro_uuid","crates/model-entity","crates/model-error-response",+ "crates/model_file_type","crates/model_user","crates/models_pagination",+ "crates/models_properties",+ "crates/non_empty","crates/notification","crates/rate_limit","crates/remote_env_var",@@ -2733,8 +2743,6 @@"crates/foreign_entity","crates/frecency","crates/graphql_common",- "crates/graphql_notification",- "crates/graphql_properties","crates/graphql_soup","crates/invite_email","crates/ip_extractor",diff --git a/Cargo.lock b/Cargo.lockindex 865b46f921..e43792d860 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2856,6 +2856,7 @@ dependencies = ["graphql_properties","graphql_soup","macro_user_id",+ "model-entity","model_user","models_pagination","soup",@@ -5937,8 +5938,10 @@ dependencies = ["async-graphql","axum","filter_ast",+ "item_filters","macro_user_id","model-entity",+ "models_properties","tokio","uuid","workspace-hack",@@ -5966,9 +5969,7 @@ dependencies = ["async-graphql","chrono","entity_access",- "filter_ast","graphql_common",- "item_filters","macro_user_id","model-entity","models_properties",@@ -5994,8 +5995,6 @@ dependencies = ["entity_access","filter_ast","graphql_common",- "graphql_notification",- "graphql_properties","item_filters","macro_user_id","model-entity",diff --git a/crates/complete_graph/Cargo.toml b/crates/complete_graph/Cargo.tomlindex 862f039976..3dad15e162 100644--- a/crates/complete_graph/Cargo.toml+++ b/crates/complete_graph/Cargo.toml@@ -21,6 +21,7 @@ graphql_common = { path = "../graphql_common" }graphql_notification = { path = "../graphql_notification" }graphql_properties = { path = "../graphql_properties" }graphql_soup = { path = "../graphql_soup" }+model-entity = { path = "../model-entity" }model_user = { path = "../model_user", features = ["axum"] }soup = { path = "../soup", default-features = false, features = ["ports"] }workspace-hack = { version = "0.1", path = "../workspace-hack" }diff --git a/crates/complete_graph/src/edges.rs b/crates/complete_graph/src/edges.rsnew file mode 100644index 0000000000..5b673c098e--- /dev/null+++ b/crates/complete_graph/src/edges.rs@@ -0,0 +1,60 @@+use std::marker::PhantomData;++use async_graphql::{Context, Object};+use graphql_notification::{+ GraphqlSoupNotification, SoupNotificationEdgeReader, load_entity_notifications,+};+use graphql_properties::{GraphqlSoupProperty, SoupPropertyEdgeReader, load_entity_properties};+use graphql_soup::SoupEntityEdges;++/// Notification and property fields attached to property-bearing Soup entities.+///+/// This concrete edge shape lives in the composition crate so `graphql_soup`+/// does not know which cross-domain fields are attached to its objects.+pub struct SoupEdges<NR, PR> {+ entity: model_entity::Entity<'static>,+ _readers: PhantomData<fn() -> (NR, PR)>,+}++impl<NR, PR> Clone for SoupEdges<NR, PR> {+ fn clone(&self) -> Self {+ Self {+ entity: self.entity.clone(),+ _readers: PhantomData,+ }+ }+}++impl<NR, PR> SoupEntityEdges for SoupEdges<NR, PR>+where+ NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,+{+ fn from_entity(entity: model_entity::Entity<'static>) -> Self {+ Self {+ entity,+ _readers: PhantomData,+ }+ }+}++#[Object(name = "SoupEdges")]+impl<NR, PR> SoupEdges<NR, PR>+where+ NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,+{+ async fn properties(+ &self,+ ctx: &Context<'_>,+ ) -> async_graphql::Result<Vec<GraphqlSoupProperty>> {+ load_entity_properties::<PR>(ctx, self.entity.clone()).await+ }++ async fn notifications(+ &self,+ ctx: &Context<'_>,+ ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {+ load_entity_notifications::<NR>(ctx, self.entity.clone()).await+ }+}diff --git a/crates/complete_graph/src/lib.rs b/crates/complete_graph/src/lib.rsindex a7d2f95ad6..1d3b5d8e0b 100644--- a/crates/complete_graph/src/lib.rs+++ b/crates/complete_graph/src/lib.rs@@ -3,18 +3,20 @@//! served by `document_storage_service` and exported as SDL.#![deny(missing_docs)]+mod edges;mod schema;#[cfg(test)]mod sdl_test;+pub use edges::SoupEdges;pub use graphql_common::GraphqlSoupRequestParts;pub use graphql_notification::{EntityNotificationsLoader, SoupNotificationEdgeReader, entity_notifications_loader,};pub use graphql_properties::{- EntityPropertiesLoader, EntityPropertyWriter, PropertiesEntityPropertyWriter,- PropertiesMutationRoot, PropertiesSoupPropertyEdgeReader, SoupPropertyEdgeReader,- entity_properties_loader,+ EntityPropertiesLoader, EntityPropertyWriter, NoOpSoupPropertyEdgeReader,+ PropertiesEntityPropertyWriter, PropertiesMutationRoot, PropertiesSoupPropertyEdgeReader,+ SoupPropertyEdgeReader, entity_properties_loader,};pub use graphql_soup::SharedSoupService;pub use schema::{diff --git a/crates/complete_graph/src/schema.rs b/crates/complete_graph/src/schema.rsindex b46d120e08..b313bef10f 100644--- a/crates/complete_graph/src/schema.rs+++ b/crates/complete_graph/src/schema.rs@@ -13,22 +13,28 @@ use email::{use entity_access::domain::ports::{EntityAccessService, NoOpEntityAccessService};use graphql_common::extract_part;use graphql_notification::{NoOpSoupNotificationEdgeReader, SoupNotificationEdgeReader};-use graphql_properties::{EntityPropertyWriter, NoOpEntityPropertyWriter, PropertiesMutationRoot};+use graphql_properties::{+ EntityPropertyWriter, NoOpEntityPropertyWriter, NoOpSoupPropertyEdgeReader,+ PropertiesMutationRoot, SoupPropertyEdgeReader,+};use graphql_soup::{SharedSoupService, SoupInput, SoupPage, resolve_soup};use model_user::axum_extractor::MacroUserExtractor;use soup::domain::ports::{NoOpSoupService, SoupService};+use crate::SoupEdges;+/// GraphQL Soup schema type.////// `S` is the soup service, `E` the email service, `EAS` the entity access/// service, `St` the embedding axum router state, `W` the property mutation-/// writer, and `NR` the notification edge reader.-pub type SoupSchema<S, E, EAS, St, W, NR> =- Schema<SoupQueryRoot<S, E, EAS, St, NR>, PropertiesMutationRoot<W>, EmptySubscription>;+/// writer, `NR` the notification edge reader, and `PR` the property edge+/// reader.+pub type SoupSchema<S, E, EAS, St, W, NR, PR> =+ Schema<SoupQueryRoot<S, E, EAS, St, NR, PR>, PropertiesMutationRoot<W>, EmptySubscription>;/// GraphQL Soup schema type backed by a shared soup service.-pub type SharedSoupSchema<S, E, EAS, St, W, NR> =- SoupSchema<SharedSoupService<S>, E, EAS, St, W, NR>;+pub type SharedSoupSchema<S, E, EAS, St, W, NR, PR> =+ SoupSchema<SharedSoupService<S>, E, EAS, St, W, NR, PR>;/// GraphQL Soup schema type backed by the no-op services, used only for/// SDL export or introspection.@@ -39,6 +45,7 @@ pub type SchemaOnlySoupSchema = SoupSchema<SchemaOnlyState,NoOpEntityPropertyWriter,NoOpSoupNotificationEdgeReader,+ NoOpSoupPropertyEdgeReader,>;/// Axum-style state used only to construct the GraphQL schema for SDL export.@@ -59,15 +66,15 @@ impl FromRef<SchemaOnlyState> for Arc<NoOpEntityAccessService> {/// Zero-sized marker tying the query objects to the email/entity-access/state/// generics without requiring values of those types.-type ServicesMarker<E, EAS, St, NR> = PhantomData<fn() -> (E, EAS, St, NR)>;+type ServicesMarker<E, EAS, St, NR, PR> = PhantomData<fn() -> (E, EAS, St, NR, PR)>;/// Root GraphQL query object for Soup.-pub struct SoupQueryRoot<S, E, EAS, St, NR> {+pub struct SoupQueryRoot<S, E, EAS, St, NR, PR> {service: S,- _marker: ServicesMarker<E, EAS, St, NR>,+ _marker: ServicesMarker<E, EAS, St, NR, PR>,}-impl<S, E, EAS, St, NR> SoupQueryRoot<S, E, EAS, St, NR> {+impl<S, E, EAS, St, NR, PR> SoupQueryRoot<S, E, EAS, St, NR, PR> {/// Create a root GraphQL query object.pub fn new(service: S) -> Self {Self {@@ -80,9 +87,9 @@ impl<S, E, EAS, St, NR> SoupQueryRoot<S, E, EAS, St, NR> {/// The authenticated user (viewer). All user-scoped data hangs off this/// object so clients (and their normalized caches) observe data ownership/// structurally rather than implicitly through the session.-pub struct GraphqlUser<S, E, EAS, St, NR> {+pub struct GraphqlUser<S, E, EAS, St, NR, PR> {service: S,- _marker: ServicesMarker<E, EAS, St, NR>,+ _marker: ServicesMarker<E, EAS, St, NR, PR>,}/// Build a GraphQL schema for Soup suitable for SDL export or introspection.@@ -91,9 +98,9 @@ pub fn build_schema() -> SchemaOnlySoupSchema {}/// Build a GraphQL schema for Soup backed by the provided service.-pub fn build_schema_with_service<S, E, EAS, St, W, NR>(+pub fn build_schema_with_service<S, E, EAS, St, W, NR, PR>(service: S,-) -> SoupSchema<S, E, EAS, St, W, NR>+) -> SoupSchema<S, E, EAS, St, W, NR, PR>whereS: SoupService + Clone,E: EmailService,@@ -103,6 +110,7 @@ whereArc<EAS>: FromRef<St>,W: EntityPropertyWriter,NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,{Schema::build(SoupQueryRoot::new(service),@@ -113,9 +121,9 @@ where}/// Build a GraphQL schema for Soup backed by an `Arc`-shared service.-pub fn build_schema_from_arc<S, E, EAS, St, W, NR>(+pub fn build_schema_from_arc<S, E, EAS, St, W, NR, PR>(service: Arc<S>,-) -> SharedSoupSchema<S, E, EAS, St, W, NR>+) -> SharedSoupSchema<S, E, EAS, St, W, NR, PR>whereS: SoupService,E: EmailService,@@ -125,12 +133,13 @@ whereArc<EAS>: FromRef<St>,W: EntityPropertyWriter,NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,{build_schema_with_service(SharedSoupService::new(service))}#[Object]-impl<S, E, EAS, St, NR> SoupQueryRoot<S, E, EAS, St, NR>+impl<S, E, EAS, St, NR, PR> SoupQueryRoot<S, E, EAS, St, NR, PR>whereS: SoupService + Clone,E: EmailService,@@ -139,9 +148,10 @@ whereEmailRouterState<E>: FromRef<St>,Arc<EAS>: FromRef<St>,NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,{/// The authenticated user.- async fn user(&self) -> GraphqlUser<S, E, EAS, St, NR> {+ async fn user(&self) -> GraphqlUser<S, E, EAS, St, NR, PR> {GraphqlUser {service: self.service.clone(),_marker: PhantomData,@@ -150,7 +160,7 @@ where}#[Object(name = "GraphqlUser")]-impl<S, E, EAS, St, NR> GraphqlUser<S, E, EAS, St, NR>+impl<S, E, EAS, St, NR, PR> GraphqlUser<S, E, EAS, St, NR, PR>whereS: SoupService,E: EmailService,@@ -159,6 +169,7 @@ whereEmailRouterState<E>: FromRef<St>,Arc<EAS>: FromRef<St>,NR: SoupNotificationEdgeReader,+ PR: SoupPropertyEdgeReader,{/// Stable id of the authenticated user.async fn id(&self, ctx: &Context<'_>) -> async_graphql::Result<async_graphql::ID> {@@ -172,7 +183,7 @@ where&self,ctx: &Context<'_>,input: SoupInput,- ) -> async_graphql::Result<SoupPage<NR>> {- resolve_soup::<S, E, EAS, St, NR>(&self.service, ctx, input).await+ ) -> async_graphql::Result<SoupPage<SoupEdges<NR, PR>>> {+ resolve_soup::<S, E, EAS, St, SoupEdges<NR, PR>>(&self.service, ctx, input).await}}diff --git a/crates/complete_graph/src/schema/test.rs b/crates/complete_graph/src/schema/test.rsindex a6978d3fe2..0f4327a479 100644--- a/crates/complete_graph/src/schema/test.rs+++ b/crates/complete_graph/src/schema/test.rs@@ -269,6 +269,7 @@ struct TestHarness {TestState,NoOpEntityPropertyWriter,NoOpSoupNotificationEdgeReader,+ NoOpSoupPropertyEdgeReader,>,state: TestState,inbox_calls: Arc<AtomicUsize>,diff --git a/crates/graphql_common/Cargo.toml b/crates/graphql_common/Cargo.tomlindex dfc58f3692..efa428440d 100644--- a/crates/graphql_common/Cargo.toml+++ b/crates/graphql_common/Cargo.toml@@ -8,8 +8,10 @@ publish = falseasync-graphql = { workspace = true }axum = { workspace = true }filter_ast = { path = "../filter_ast" }+item_filters = { path = "../item_filters" }macro_user_id = { path = "../macro_user_id" }model-entity = { path = "../model-entity" }+models_properties = { path = "../models_properties" }tokio = { workspace = true }uuid = { workspace = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }diff --git a/crates/graphql_common/src/lib.rs b/crates/graphql_common/src/lib.rsindex 8ae5ace2a9..38c0eaf703 100644--- a/crates/graphql_common/src/lib.rs+++ b/crates/graphql_common/src/lib.rs@@ -9,9 +9,14 @@ pub use filter_ast;mod entity_type;mod extract;mod filter_input;+mod property_filter;mod request_context;pub use entity_type::GraphqlSoupEntityType;pub use extract::extract_part;pub use filter_input::{IntoFilterExpr, optional_tree, parse_id, parse_macro_user_id, parse_uuid};+pub use property_filter::{+ GraphqlPropertiesBinaryExpr, GraphqlPropertiesExpr, GraphqlPropertiesLiteral,+ GraphqlPropertyEntityType, GraphqlPropertyMatchValue,+};pub use request_context::GraphqlSoupRequestParts;diff --git a/crates/graphql_properties/src/inputs.rs b/crates/graphql_common/src/property_filter.rssimilarity index 91%rename from crates/graphql_properties/src/inputs.rsrename to crates/graphql_common/src/property_filter.rsindex d38bd03901..44ac49ad52 100644--- a/crates/graphql_properties/src/inputs.rs+++ b/crates/graphql_common/src/property_filter.rs@@ -1,10 +1,17 @@+//! Legacy GraphQL bridge for property-aware Soup filters.+//!+//! Soup historically returned and filtered properties directly. New code+//! should avoid adding property concepts to Soup, and existing usages should+//! move toward the properties domain boundary so this module can be removed.+use async_graphql::{Enum, ID};use filter_ast::Expr;-use graphql_common::{IntoFilterExpr, filter_expr_input, parse_id};use item_filters::ast::properties::{EntityRefId, PropertiesLiteral, PropertyEntityType, PropertyMatchValue,};+use crate::{IntoFilterExpr, filter_expr_input, parse_id};+filter_expr_input!(GraphqlPropertiesExpr,GraphqlPropertiesBinaryExpr,diff --git a/crates/graphql_properties/Cargo.toml b/crates/graphql_properties/Cargo.tomlindex d11f96ddc8..2b1f63319b 100644--- a/crates/graphql_properties/Cargo.toml+++ b/crates/graphql_properties/Cargo.toml@@ -8,9 +8,7 @@ version = "0.1.0"async-graphql = { workspace = true, features = ["dataloader"] }chrono = { workspace = true }entity_access = { path = "../entity_access", default-features = false }-filter_ast = { path = "../filter_ast" }graphql_common = { path = "../graphql_common" }-item_filters = { path = "../item_filters" }macro_user_id = { path = "../macro_user_id" }model-entity = { path = "../model-entity" }models_properties = { path = "../models_properties" }diff --git a/crates/graphql_properties/src/lib.rs b/crates/graphql_properties/src/lib.rsindex d34e3eb5fd..c8af010d51 100644--- a/crates/graphql_properties/src/lib.rs+++ b/crates/graphql_properties/src/lib.rs@@ -2,15 +2,16 @@//! property filter inputs, and the DataLoader-backed entity property edge.#![deny(missing_docs)]-mod inputs;mod loaders;mod mutations;mod objects;-pub use inputs::{GraphqlPropertiesBinaryExpr, GraphqlPropertiesExpr};+pub use graphql_common::{+ GraphqlPropertiesBinaryExpr, GraphqlPropertiesExpr, GraphqlPropertyEntityType,+};pub use loaders::{- EntityPropertiesLoader, PropertiesSoupPropertyEdgeReader, SoupPropertyEdgeReader,- entity_properties_loader,+ EntityPropertiesLoader, NoOpSoupPropertyEdgeReader, PropertiesSoupPropertyEdgeReader,+ SoupPropertyEdgeReader, entity_properties_loader,};pub use mutations::{EntityPropertyWriter, NoOpEntityPropertyWriter, PropertiesEntityPropertyWriter,@@ -18,4 +19,5 @@ pub use mutations::{};pub use objects::{GraphqlSoupProperty, GraphqlSoupPropertyEntityReference, GraphqlSoupPropertyValue,+ load_entity_properties,};diff --git a/crates/graphql_properties/src/loaders.rs b/crates/graphql_properties/src/loaders.rsindex 9356384c2d..db466a8128 100644--- a/crates/graphql_properties/src/loaders.rs+++ b/crates/graphql_properties/src/loaders.rs@@ -35,6 +35,20 @@ pub trait SoupPropertyEdgeReader: Send + Sync + 'static {> + Send;}+/// Property reader used by schema-only GraphQL construction.+#[derive(Clone, Copy, Debug, Default)]+pub struct NoOpSoupPropertyEdgeReader;++impl SoupPropertyEdgeReader for NoOpSoupPropertyEdgeReader {+ async fn get_properties(+ &self,+ _user_id: &MacroUserIdStr<'static>,+ keys: &[model_entity::Entity<'static>],+ ) -> Result<HashMap<model_entity::Entity<'static>, Vec<SoupProperty>>, rootcause::Report> {+ Ok(keys.iter().cloned().map(|key| (key, Vec::new())).collect())+ }+}+/// GraphQL property reader backed by the properties domain service and the/// canonical entity access service.pub struct PropertiesSoupPropertyEdgeReader<P, A> {diff --git a/crates/graphql_properties/src/mutations.rs b/crates/graphql_properties/src/mutations.rsindex 83c4a79ca8..90d08fd063 100644--- a/crates/graphql_properties/src/mutations.rs+++ b/crates/graphql_properties/src/mutations.rs@@ -1,7 +1,7 @@use async_graphql::{Context, ID, Object};use entity_access::domain::models::EditAccessLevel;use entity_access::domain::ports::EntityAccessService;-use graphql_common::parse_id;+use graphql_common::{GraphqlPropertyEntityType, parse_id};use macro_user_id::user_id::MacroUserIdStr;use models_properties::api::requests::SetPropertyValue;use models_properties::shared::EntityReference;@@ -10,7 +10,7 @@ use properties::{PropertiesAccessReceipt, PropertiesService, access_entity_type}use std::{marker::PhantomData, sync::Arc};use uuid::Uuid;-use crate::{inputs::GraphqlPropertyEntityType, objects::GraphqlSoupProperty};+use crate::objects::GraphqlSoupProperty;/// Mutation root for entity property writes.#[derive(Default)]diff --git a/crates/graphql_properties/src/objects.rs b/crates/graphql_properties/src/objects.rsindex a497a312b6..22e9d94da7 100644--- a/crates/graphql_properties/src/objects.rs+++ b/crates/graphql_properties/src/objects.rs@@ -1,7 +1,9 @@-use async_graphql::{Enum, ID, Object, SimpleObject};+use async_graphql::{Context, Enum, ID, Object, SimpleObject, dataloader::DataLoader};use models_properties::service::property_value::PropertyValue;use models_soup::SoupProperty;+use crate::loaders::{EntityPropertiesLoader, SoupPropertyEdgeReader};+/// GraphQL representation of supported Soup property data types.#[derive(Enum, Clone, Copy, PartialEq, Eq)]pub enum GraphqlSoupDataType {@@ -41,6 +43,26 @@ impl From<models_properties::DataType> for GraphqlSoupDataType {}}+/// Load properties attached to an entity through the request-scoped loader.+pub async fn load_entity_properties<R>(+ ctx: &Context<'_>,+ entity: model_entity::Entity<'static>,+) -> async_graphql::Result<Vec<GraphqlSoupProperty>>+where+ R: SoupPropertyEdgeReader,+{+ let loader = ctx.data::<DataLoader<EntityPropertiesLoader<R>>>()?;+ let properties = loader+ .load_one(model_entity::OwnedEntity::from(entity))+ .await+ .map_err(|err| async_graphql::Error::new(err.to_string()))?+ .unwrap_or_default();+ Ok(properties+ .into_iter()+ .map(GraphqlSoupProperty::from)+ .collect())+}+/// GraphQL property assignment attached to a Soup entity.pub struct GraphqlSoupProperty(SoupProperty);diff --git a/crates/graphql_soup/Cargo.toml b/crates/graphql_soup/Cargo.tomlindex 929111a236..4bff4f87f6 100644--- a/crates/graphql_soup/Cargo.toml+++ b/crates/graphql_soup/Cargo.toml@@ -20,8 +20,6 @@ entity_access = { path = "../entity_access", default-features = false, features] }filter_ast = { path = "../filter_ast" }graphql_common = { path = "../graphql_common" }-graphql_notification = { path = "../graphql_notification" }-graphql_properties = { path = "../graphql_properties" }item_filters = { path = "../item_filters" }macro_user_id = { path = "../macro_user_id" }model_file_type = { path = "../model_file_type" }diff --git a/crates/graphql_soup/src/inputs.rs b/crates/graphql_soup/src/inputs.rsindex 0725536847..9229f7c37b 100644--- a/crates/graphql_soup/src/inputs.rs+++ b/crates/graphql_soup/src/inputs.rs@@ -5,9 +5,9 @@ use chrono::{DateTime, Utc};use document_sub_type::DocumentSubType;use filter_ast::Expr;use graphql_common::{- IntoFilterExpr, filter_expr_input, optional_tree, parse_id, parse_macro_user_id,+ GraphqlPropertiesExpr, IntoFilterExpr, filter_expr_input, optional_tree, parse_id,+ parse_macro_user_id,};-use graphql_properties::GraphqlPropertiesExpr;use item_filters::{CallStatus, SharedEmailFilter,ast::{diff --git a/crates/graphql_soup/src/lib.rs b/crates/graphql_soup/src/lib.rsindex 8e6e13f156..ac9b990053 100644--- a/crates/graphql_soup/src/lib.rs+++ b/crates/graphql_soup/src/lib.rs@@ -10,18 +10,11 @@ mod objects;mod resolvers;pub use graphql_common::{GraphqlSoupEntityType, GraphqlSoupRequestParts};-pub use graphql_notification::{- EntityNotificationsLoader, GraphqlSoupNotification, SoupNotificationEdgeReader,- entity_notifications_loader,-};-pub use graphql_properties::{- EntityPropertiesLoader, GraphqlSoupProperty, GraphqlSoupPropertyEntityReference,- GraphqlSoupPropertyValue, SoupPropertyEdgeReader, entity_properties_loader,-};pub use inputs::{GraphqlSimpleSortMethod, SoupInput};pub use objects::{GraphqlSoupCall, GraphqlSoupChannel, GraphqlSoupChannelThread, GraphqlSoupChat,GraphqlSoupCrmCompany, GraphqlSoupDocument, GraphqlSoupDocumentSubType, GraphqlSoupEmailThread,- GraphqlSoupEntity, GraphqlSoupForeignEntity, GraphqlSoupItem, GraphqlSoupProject, SoupPage,+ GraphqlSoupEntity, GraphqlSoupForeignEntity, GraphqlSoupItem, GraphqlSoupProject,+ SoupEntityEdges, SoupPage,};pub use resolvers::{SharedSoupService, resolve_soup};diff --git a/crates/graphql_soup/src/objects.rs b/crates/graphql_soup/src/objects.rsindex 6b6538f142..19eb084670 100644--- a/crates/graphql_soup/src/objects.rs+++ b/crates/graphql_soup/src/objects.rs@@ -1,11 +1,5 @@-use std::marker::PhantomData;--use async_graphql::{Context, ID, Json, Object, Union};+use async_graphql::{ID, Json, Object, ObjectType, Union};use graphql_common::GraphqlSoupEntityType;-use graphql_notification::{- GraphqlSoupNotification, SoupNotificationEdgeReader, load_entity_notifications,-};-use graphql_properties::GraphqlSoupProperty;use models_pagination::PaginatedOpaqueCursor;use models_soup::{call_record::{SoupCallRecord, SoupCallRecordParticipant},@@ -24,21 +18,30 @@ use models_soup::{use serde_json::Value;use soup::domain::models::FrecencySoupItem;+/// Extension fields attached to every top-level Soup entity.+///+/// The concrete edge object is supplied by the schema composition crate and+/// flattened into each Soup entity's GraphQL fields.+pub trait SoupEntityEdges: ObjectType + Clone + Send + Sync + 'static {+ /// Construct the edge object for a Soup entity.+ fn from_entity(entity: model_entity::Entity<'static>) -> Self;+}+/// Page returned by `Query.soup`.-pub struct SoupPage<R: SoupNotificationEdgeReader> {- items: Vec<GraphqlSoupItem<R>>,+pub struct SoupPage<E: SoupEntityEdges> {+ items: Vec<GraphqlSoupItem<E>>,next_cursor: Option<String>,has_more: bool,}/// Page returned by `Query.soup`.#[Object(name = "SoupPage")]-impl<R> SoupPage<R>+impl<E> SoupPage<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{/// Items in the current page.- async fn items(&self) -> &[GraphqlSoupItem<R>] {+ async fn items(&self) -> &[GraphqlSoupItem<E>] {&self.items}@@ -53,7 +56,7 @@ where}}-impl<R: SoupNotificationEdgeReader> From<PaginatedOpaqueCursor<FrecencySoupItem>> for SoupPage<R> {+impl<E: SoupEntityEdges> From<PaginatedOpaqueCursor<FrecencySoupItem>> for SoupPage<E> {fn from(page: PaginatedOpaqueCursor<FrecencySoupItem>) -> Self {let has_more = page.next_cursor.is_some();Self {@@ -65,17 +68,17 @@ impl<R: SoupNotificationEdgeReader> From<PaginatedOpaqueCursor<FrecencySoupItem>}/// GraphQL Soup item envelope.-pub struct GraphqlSoupItem<R: SoupNotificationEdgeReader> {+pub struct GraphqlSoupItem<E: SoupEntityEdges> {id: String,entity_type: GraphqlSoupEntityType,frecency_score: f64,- entity: GraphqlSoupEntity<R>,+ entity: GraphqlSoupEntity<E>,}#[Object(name = "GraphqlSoupItem")]-impl<R> GraphqlSoupItem<R>+impl<E> GraphqlSoupItem<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.id.clone())@@ -89,12 +92,12 @@ whereself.frecency_score}- async fn entity(&self) -> &GraphqlSoupEntity<R> {+ async fn entity(&self) -> &GraphqlSoupEntity<E> {&self.entity}}-impl<R: SoupNotificationEdgeReader> From<FrecencySoupItem> for GraphqlSoupItem<R> {+impl<E: SoupEntityEdges> From<FrecencySoupItem> for GraphqlSoupItem<E> {fn from(item: FrecencySoupItem) -> Self {let FrecencySoupItem {item,@@ -116,61 +119,101 @@ impl<R: SoupNotificationEdgeReader> From<FrecencySoupItem> for GraphqlSoupItem<R/// GraphQL union over expanded Soup entity variants.#[derive(Union)]-pub enum GraphqlSoupEntity<R: SoupNotificationEdgeReader> {+pub enum GraphqlSoupEntity<E: SoupEntityEdges> {/// Document entity.- Document(GraphqlSoupDocument<R>),+ Document(GraphqlSoupDocument<E>),/// Chat entity.- Chat(GraphqlSoupChat<R>),+ Chat(GraphqlSoupChat<E>),/// Project entity.- Project(GraphqlSoupProject<R>),+ Project(GraphqlSoupProject<E>),/// Email thread entity.- EmailThread(GraphqlSoupEmailThread<R>),+ EmailThread(GraphqlSoupEmailThread<E>),/// Channel entity.- Channel(GraphqlSoupChannel<R>),+ Channel(GraphqlSoupChannel<E>),/// Channel thread entity.- ChannelThread(GraphqlSoupChannelThread<R>),+ ChannelThread(GraphqlSoupChannelThread<E>),/// Call entity.- Call(GraphqlSoupCall<R>),+ Call(GraphqlSoupCall<E>),/// CRM company entity.- CrmCompany(GraphqlSoupCrmCompany<R>),+ CrmCompany(GraphqlSoupCrmCompany<E>),/// Foreign entity.- ForeignEntity(GraphqlSoupForeignEntity<R>),+ ForeignEntity(GraphqlSoupForeignEntity<E>),}-impl<R> From<SoupItem> for GraphqlSoupEntity<R>+impl<E> From<SoupItem> for GraphqlSoupEntity<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{fn from(item: SoupItem) -> Self {match item {- SoupItem::Document(item) => Self::Document(GraphqlSoupDocument(item, PhantomData)),- SoupItem::Chat(item) => Self::Chat(GraphqlSoupChat(item, PhantomData)),- SoupItem::Project(item) => Self::Project(GraphqlSoupProject(item, PhantomData)),+ SoupItem::Document(item) => {+ let edges = E::from_entity(+ model_entity::EntityType::Document.with_entity_string(item.id.to_string()),+ );+ Self::Document(GraphqlSoupDocument(item, edges))+ }+ SoupItem::Chat(item) => {+ let edges = E::from_entity(+ model_entity::EntityType::Chat.with_entity_string(item.id.to_string()),+ );+ Self::Chat(GraphqlSoupChat(item, edges))+ }+ SoupItem::Project(item) => {+ let edges = E::from_entity(+ model_entity::EntityType::Project.with_entity_string(item.id.to_string()),+ );+ Self::Project(GraphqlSoupProject(item, edges))+ }SoupItem::EmailThread(item) => {- Self::EmailThread(GraphqlSoupEmailThread(item, PhantomData))+ let edges = E::from_entity(+ model_entity::EntityType::EmailThread+ .with_entity_string(item.thread.id.to_string()),+ );+ Self::EmailThread(GraphqlSoupEmailThread(item, edges))+ }+ SoupItem::Channel(item) => {+ let edges = E::from_entity(+ model_entity::EntityType::Channel+ .with_entity_string(item.channel.channel.id.0.to_string()),+ );+ Self::Channel(GraphqlSoupChannel(item, edges))}- SoupItem::Channel(item) => Self::Channel(GraphqlSoupChannel(item, PhantomData)),SoupItem::ChannelThread(item) => {- Self::ChannelThread(GraphqlSoupChannelThread(item, PhantomData))+ let edges = E::from_entity(+ model_entity::EntityType::ChannelMessage+ .with_entity_string(item.id.to_string()),+ );+ Self::ChannelThread(GraphqlSoupChannelThread(item, edges))+ }+ SoupItem::Call(item) => {+ let edges = E::from_entity(+ model_entity::EntityType::Call.with_entity_string(item.call_id.to_string()),+ );+ Self::Call(GraphqlSoupCall(item, edges))}- SoupItem::Call(item) => Self::Call(GraphqlSoupCall(item, PhantomData)),SoupItem::CrmCompany(item) => {- Self::CrmCompany(GraphqlSoupCrmCompany(item, PhantomData))+ let edges = E::from_entity(+ model_entity::EntityType::CrmCompany.with_entity_string(item.id.to_string()),+ );+ Self::CrmCompany(GraphqlSoupCrmCompany(item, edges))}SoupItem::ForeignEntity(item) => {- Self::ForeignEntity(GraphqlSoupForeignEntity(item, PhantomData))+ let edges = E::from_entity(+ model_entity::EntityType::ForeignEntity.with_entity_string(item.id.to_string()),+ );+ Self::ForeignEntity(GraphqlSoupForeignEntity(item, edges))}}}}/// GraphQL document entity.-pub struct GraphqlSoupDocument<R: SoupNotificationEdgeReader>(SoupDocument, PhantomData<R>);+pub struct GraphqlSoupDocument<E: SoupEntityEdges>(SoupDocument, E);#[Object(name = "GraphqlSoupDocument")]-impl<R> GraphqlSoupDocument<R>+impl<E> GraphqlSoupDocument<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -215,24 +258,9 @@ where.map(GraphqlSoupDocumentSubType::from)}- async fn properties(&self) -> Vec<GraphqlSoupProperty> {- self.0- .properties- .iter()- .cloned()- .map(GraphqlSoupProperty::from)- .collect()- }-- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::Document.with_entity_string(self.0.id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}@@ -269,12 +297,12 @@ impl GraphqlSoupDocumentSubType {}/// GraphQL chat entity.-pub struct GraphqlSoupChat<R: SoupNotificationEdgeReader>(SoupChat, PhantomData<R>);+pub struct GraphqlSoupChat<E: SoupEntityEdges>(SoupChat, E);#[Object(name = "GraphqlSoupChat")]-impl<R> GraphqlSoupChat<R>+impl<E> GraphqlSoupChat<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -312,34 +340,19 @@ whereself.0.deleted_at.map(|ts| ts.to_rfc3339())}- async fn properties(&self) -> Vec<GraphqlSoupProperty> {- self.0- .properties- .iter()- .cloned()- .map(GraphqlSoupProperty::from)- .collect()- }-- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::Chat.with_entity_string(self.0.id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}/// GraphQL project entity.-pub struct GraphqlSoupProject<R: SoupNotificationEdgeReader>(SoupProject, PhantomData<R>);+pub struct GraphqlSoupProject<E: SoupEntityEdges>(SoupProject, E);#[Object(name = "GraphqlSoupProject")]-impl<R> GraphqlSoupProject<R>+impl<E> GraphqlSoupProject<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -373,24 +386,9 @@ whereself.0.deleted_at.map(|ts| ts.to_rfc3339())}- async fn properties(&self) -> Vec<GraphqlSoupProperty> {- self.0- .properties- .iter()- .cloned()- .map(GraphqlSoupProperty::from)- .collect()- }-- async fn notifications<'a>(- &'a self,- ctx: &'a Context<'a>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::Project.with_entity_string(self.0.id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}@@ -573,15 +571,12 @@ impl GraphqlSoupEmailAttachment {}/// GraphQL email thread entity.-pub struct GraphqlSoupEmailThread<R: SoupNotificationEdgeReader>(- SoupEnrichedEmailThreadPreview,- PhantomData<R>,-);+pub struct GraphqlSoupEmailThread<E: SoupEntityEdges>(SoupEnrichedEmailThreadPreview, E);#[Object(name = "GraphqlSoupEmailThread")]-impl<R> GraphqlSoupEmailThread<R>+impl<E> GraphqlSoupEmailThread<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.thread.id.to_string())@@ -692,24 +687,9 @@ where.collect()}- async fn properties(&self) -> Vec<GraphqlSoupProperty> {- self.0- .properties- .iter()- .cloned()- .map(GraphqlSoupProperty::from)- .collect()- }-- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::EmailThread.with_entity_string(self.0.thread.id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}@@ -785,9 +765,9 @@ impl GraphqlSoupChannelMessage {}/// GraphQL channel entity.-pub struct GraphqlSoupChannel<R: SoupNotificationEdgeReader>(SoupChannel, PhantomData<R>);+pub struct GraphqlSoupChannel<E: SoupEntityEdges>(SoupChannel, E);-impl<R: SoupNotificationEdgeReader> GraphqlSoupChannel<R> {+impl<E: SoupEntityEdges> GraphqlSoupChannel<E> {fn channel_type_name(channel_type: ChannelType) -> &'static str {match channel_type {ChannelType::Public => "public",@@ -799,9 +779,9 @@ impl<R: SoupNotificationEdgeReader> GraphqlSoupChannel<R> {}#[Object(name = "GraphqlSoupChannel")]-impl<R> GraphqlSoupChannel<R>+impl<E> GraphqlSoupChannel<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.channel.channel.id.0.to_string())@@ -887,29 +867,19 @@ where.map(GraphqlSoupChannelMessage)}- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::Channel- .with_entity_string(self.0.channel.channel.id.0.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}/// GraphQL channel thread entity.-pub struct GraphqlSoupChannelThread<R: SoupNotificationEdgeReader>(- SoupChannelThread,- PhantomData<R>,-);+pub struct GraphqlSoupChannelThread<E: SoupEntityEdges>(SoupChannelThread, E);#[Object(name = "GraphqlSoupChannelThread")]-impl<R> GraphqlSoupChannelThread<R>+impl<E> GraphqlSoupChannelThread<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -943,15 +913,9 @@ whereself.0.thread.reply_count}- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::ChannelMessage.with_entity_string(self.0.id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}@@ -988,12 +952,12 @@ impl GraphqlSoupCallParticipant {}/// GraphQL call entity.-pub struct GraphqlSoupCall<R: SoupNotificationEdgeReader>(SoupCallRecord, PhantomData<R>);+pub struct GraphqlSoupCall<E: SoupEntityEdges>(SoupCallRecord, E);#[Object(name = "GraphqlSoupCall")]-impl<R> GraphqlSoupCall<R>+impl<E> GraphqlSoupCall<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.call_id.to_string())@@ -1074,25 +1038,19 @@ where.collect()}- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::Call.with_entity_string(self.0.call_id.to_string()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}/// GraphQL CRM company entity.-pub struct GraphqlSoupCrmCompany<R: SoupNotificationEdgeReader>(SoupCrmCompany, PhantomData<R>);+pub struct GraphqlSoupCrmCompany<E: SoupEntityEdges>(SoupCrmCompany, E);#[Object(name = "GraphqlSoupCrmCompany")]-impl<R> GraphqlSoupCrmCompany<R>+impl<E> GraphqlSoupCrmCompany<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -1138,30 +1096,19 @@ where.collect()}- async fn properties(&self) -> Vec<GraphqlSoupProperty> {- self.0- .properties- .iter()- .cloned()- .map(GraphqlSoupProperty::from)- .collect()- }-- async fn notifications(&self) -> Vec<GraphqlSoupNotification> {- Vec::new()+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}/// GraphQL foreign entity.-pub struct GraphqlSoupForeignEntity<R: SoupNotificationEdgeReader>(- SoupForeignEntity,- PhantomData<R>,-);+pub struct GraphqlSoupForeignEntity<E: SoupEntityEdges>(SoupForeignEntity, E);#[Object(name = "GraphqlSoupForeignEntity")]-impl<R> GraphqlSoupForeignEntity<R>+impl<E> GraphqlSoupForeignEntity<E>where- R: SoupNotificationEdgeReader,+ E: SoupEntityEdges,{async fn id(&self) -> ID {ID(self.0.id.to_string())@@ -1195,15 +1142,8 @@ whereself.0.updated_at.to_rfc3339()}- async fn notifications(- &self,- ctx: &Context<'_>,- ) -> async_graphql::Result<Vec<GraphqlSoupNotification>> {- load_entity_notifications::<R>(- ctx,- model_entity::EntityType::ForeignEntity- .with_entity_string(self.0.foreign_entity_id.clone()),- )- .await+ #[graphql(flatten)]+ async fn edges(&self) -> E {+ self.1.clone()}}diff --git a/crates/graphql_soup/src/resolvers.rs b/crates/graphql_soup/src/resolvers.rsindex 5b729457f5..848d2f7049 100644--- a/crates/graphql_soup/src/resolvers.rs+++ b/crates/graphql_soup/src/resolvers.rs@@ -15,12 +15,14 @@ use entity_access::{inbound::axum_extractors::OptionalMacroUserTeamExtractor,};use graphql_common::extract_part;-use graphql_notification::SoupNotificationEdgeReader;use model_user::axum_extractor::MacroUserExtractor;use models_pagination::TypeEraseCursor;use soup::domain::{models::SoupRequest, ports::SoupService};-use crate::{inputs::SoupInput, objects::SoupPage};+use crate::{+ inputs::SoupInput,+ objects::{SoupEntityEdges, SoupPage},+};/// Shared wrapper for a concrete Soup service.pub struct SharedSoupService<S>(Arc<S>);@@ -75,11 +77,11 @@ where/// Resolve a page of Soup items for the authenticated user: runs the lazy/// axum extractors against the request context, converts the GraphQL input/// into a Soup request, and executes it against the Soup service.-pub async fn resolve_soup<S, E, EAS, St, R>(+pub async fn resolve_soup<S, E, EAS, St, Edges>(service: &S,ctx: &Context<'_>,input: SoupInput,-) -> async_graphql::Result<SoupPage<R>>+) -> async_graphql::Result<SoupPage<Edges>>whereS: SoupService,E: EmailService,@@ -87,7 +89,7 @@ whereSt: Clone + Send + Sync + 'static,EmailRouterState<E>: FromRef<St>,Arc<EAS>: FromRef<St>,- R: SoupNotificationEdgeReader,+ Edges: SoupEntityEdges,{let Cached(MacroUserExtractor { macro_user_id, .. }) =extract_part::<Cached<MacroUserExtractor>, St>(ctx).await?;diff --git a/services/document_storage_service/src/api/context.rs b/services/document_storage_service/src/api/context.rsindex 1ada4c0eca..13df61cbbc 100644--- a/services/document_storage_service/src/api/context.rs+++ b/services/document_storage_service/src/api/context.rs@@ -146,6 +146,7 @@ pub(crate) type DssGraphqlSoupSchema = complete_graph::SharedSoupSchema<ApiContext,complete_graph::PropertiesEntityPropertyWriter<PropertiesService, EntityAccessService>,Arc<ai_tools::ToolNotificationService>,+ complete_graph::PropertiesSoupPropertyEdgeReader<PropertiesService, EntityAccessService>,>;type SystemPropertiesService = SystemPropertiesServiceImpl<PgSystemPropertiesRepository>;diff --git a/static_assets/schema.graphql b/static_assets/schema.graphqlindex 81e347098e..9f9d17f3d8 100644--- a/static_assets/schema.graphql+++ b/static_assets/schema.graphql@@ -425,6 +425,7 @@ type GraphqlSoupCall {participantCount: Int!participantIds: [String!]!participants: [GraphqlSoupCallParticipant!]!+ properties: [GraphqlSoupProperty!]!notifications: [GraphqlSoupNotification!]!}@@ -450,6 +451,7 @@ type GraphqlSoupChannel {participants: [GraphqlSoupChannelParticipant!]!latestMessage: GraphqlSoupChannelMessagelatestNonThreadMessage: GraphqlSoupChannelMessage+ properties: [GraphqlSoupProperty!]!notifications: [GraphqlSoupNotification!]!}@@ -481,6 +483,7 @@ type GraphqlSoupChannelThread {updatedAt: String!effectiveUpdatedAt: String!replyCount: Int!+ properties: [GraphqlSoupProperty!]!notifications: [GraphqlSoupNotification!]!}@@ -705,6 +708,7 @@ type GraphqlSoupForeignEntity {metadata: JSON!createdAt: String!updatedAt: String!+ properties: [GraphqlSoupProperty!]!notifications: [GraphqlSoupNotification!]!}