reactive_graph_graphql_schema/query/behaviours/
behaviour.rs

1use async_graphql::Object;
2
3use crate::query::GraphQLNamespacedType;
4use reactive_graph_behaviour_model_api::BehaviourTypeId;
5use reactive_graph_graph::NamespacedTypeGetter;
6
7pub struct GraphQLBehaviour {
8    behaviour_ty: BehaviourTypeId,
9}
10
11/// A behaviour.
12#[Object(name = "Behaviour")]
13impl GraphQLBehaviour {
14    /// The fully qualified namespace of the behaviour.
15    #[graphql(name = "type")]
16    async fn ty(&self) -> String {
17        self.behaviour_ty.namespace().to_string()
18    }
19
20    /// The namespaced type.
21    async fn namespaced_type(&self) -> GraphQLNamespacedType {
22        self.behaviour_ty.namespaced_type().into()
23    }
24}
25
26impl From<BehaviourTypeId> for GraphQLBehaviour {
27    fn from(behaviour_ty: BehaviourTypeId) -> Self {
28        GraphQLBehaviour { behaviour_ty }
29    }
30}