11use std:: fmt:: Display ;
22
3- use juniper:: { graphql_object, Executor , GraphQLEnum , GraphQLObject , ScalarValue } ;
3+ use juniper:: { graphql_object, Executor , FieldResult , GraphQLEnum , GraphQLObject , ScalarValue } ;
44
55use grc20_core:: {
66 mapping:: { self , query_utils:: Query , triple} ,
@@ -9,8 +9,11 @@ use grc20_core::{
99
1010use crate :: context:: KnowledgeGraph ;
1111
12+ use super :: Entity ;
13+
1214#[ derive( Debug ) ]
1315pub struct Triple {
16+ entity_id : String ,
1417 pub attribute : String ,
1518 pub value : String ,
1619 pub value_type : ValueType ,
@@ -23,6 +26,7 @@ pub struct Triple {
2326impl Triple {
2427 pub fn new ( triple : mapping:: Triple , space_id : String , space_version : Option < String > ) -> Self {
2528 Self {
29+ entity_id : triple. entity ,
2630 attribute : triple. attribute ,
2731 value : triple. value . value ,
2832 value_type : triple. value . value_type . into ( ) ,
@@ -79,6 +83,20 @@ impl Triple {
7983 . expect ( "Failed to find triple name attribute" )
8084 . map ( |triple| triple. value . value )
8185 }
86+
87+ async fn entity < ' a , S : ScalarValue > (
88+ & ' a self ,
89+ executor : & ' a Executor < ' _ , ' _ , KnowledgeGraph , S > ,
90+ ) -> FieldResult < Option < Entity > > {
91+ Entity :: load (
92+ & executor. context ( ) . neo4j ,
93+ self . entity_id . clone ( ) ,
94+ self . space_id . clone ( ) ,
95+ self . space_version . clone ( ) ,
96+ false ,
97+ )
98+ . await
99+ }
82100}
83101
84102impl From < mapping:: ValueType > for ValueType {
0 commit comments