@@ -316,6 +316,59 @@ async def test_display_hfid(db: InfrahubDatabase, default_branch: Branch, animal
316316 }
317317
318318
319+ async def test_display_hfid_related_node (
320+ db : InfrahubDatabase , default_branch : Branch , animal_person_schema : SchemaBranch
321+ ):
322+ person_schema = animal_person_schema .get (name = "TestPerson" )
323+ dog_schema = animal_person_schema .get (name = "TestDog" )
324+
325+ person1 = await Node .init (db = db , schema = person_schema , branch = default_branch )
326+ await person1 .new (db = db , name = "Jack" )
327+ await person1 .save (db = db )
328+
329+ dog1 = await Node .init (db = db , schema = dog_schema , branch = default_branch )
330+ await dog1 .new (db = db , name = "Rocky" , breed = "Labrador" , owner = person1 )
331+ await dog1 .save (db = db )
332+
333+ query = """
334+ query {
335+ TestPerson {
336+ edges {
337+ node {
338+ hfid
339+ animals {
340+ edges {
341+ node {
342+ hfid
343+ }
344+ }
345+ }
346+ }
347+ }
348+ }
349+ }
350+ """
351+ gql_params = prepare_graphql_params (
352+ db = db , include_mutation = False , include_subscription = False , branch = default_branch
353+ )
354+ result = await graphql (
355+ schema = gql_params .schema ,
356+ source = query ,
357+ context_value = gql_params .context ,
358+ root_value = None ,
359+ variable_values = {},
360+ )
361+
362+ assert result .errors is None
363+ assert len (result .data ["TestPerson" ]["edges" ]) == 1
364+ assert result .data ["TestPerson" ]["edges" ][0 ] == {
365+ "node" : {
366+ "animals" : {"edges" : [{"node" : {"hfid" : ["Jack" , "Rocky" ]}}]},
367+ "hfid" : ["Jack" ],
368+ },
369+ }
370+
371+
319372async def test_display_label_generic (db : InfrahubDatabase , default_branch : Branch , animal_person_schema : SchemaBranch ):
320373 person_schema = animal_person_schema .get (name = "TestPerson" )
321374 dog_schema = animal_person_schema .get (name = "TestDog" )
0 commit comments