Skip to content

Commit

Permalink
refactor: correct type mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Jul 29, 2024
1 parent b4a9beb commit 3e0a5b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/torii/graphql/src/object/event_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sqlx::pool::PoolConnection;
use sqlx::{Pool, Sqlite};
use tokio_stream::StreamExt;
use torii_core::simple_broker::SimpleBroker;
use torii_core::types::Entity;
use torii_core::types::EventMessage;

use super::inputs::keys_input::keys_argument;
use super::{BasicObject, ResolvableObject, TypeMapping, ValueMapping};
Expand Down Expand Up @@ -67,7 +67,7 @@ impl ResolvableObject for EventMessageObject {

fn subscriptions(&self) -> Option<Vec<SubscriptionField>> {
Some(vec![SubscriptionField::new(
"entityUpdated",
"eventMessageUpdated",
TypeRef::named_nn(self.type_name()),
|ctx| {
SubscriptionFieldFuture::new(async move {
Expand All @@ -77,7 +77,7 @@ impl ResolvableObject for EventMessageObject {
};
// if id is None, then subscribe to all entities
// if id is Some, then subscribe to only the entity with that id
Ok(SimpleBroker::<Entity>::subscribe().filter_map(move |entity: Entity| {
Ok(SimpleBroker::<EventMessage>::subscribe().filter_map(move |entity: EventMessage| {
if id.is_none() || id == Some(entity.id.clone()) {
Some(Ok(Value::Object(EventMessageObject::value_mapping(entity))))

Check warning on line 82 in crates/torii/graphql/src/object/event_message.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/graphql/src/object/event_message.rs#L80-L82

Added lines #L80 - L82 were not covered by tests
} else {
Expand All @@ -93,7 +93,7 @@ impl ResolvableObject for EventMessageObject {
}

impl EventMessageObject {
pub fn value_mapping(entity: Entity) -> ValueMapping {
pub fn value_mapping(entity: EventMessage) -> ValueMapping {
let keys: Vec<&str> = entity.keys.split('/').filter(|&k| !k.is_empty()).collect();
IndexMap::from([
(Name::new("id"), Value::from(entity.id)),
Expand Down

0 comments on commit 3e0a5b1

Please sign in to comment.