The to_graph_node() method automatically normalizes the name property for consistent display. If no name field exists, it falls back to title, label, or truncated text.
# Domain node with 'title' instead of 'name'class Book(DomainNode): title: str author: Optional[str] =Nonebook = Book(title="The Art of War", author="Sun Tzu")graph_node = book.to_graph_node()# 'name' is auto-populated from 'title'print(f"Properties: {graph_node.properties}")assert graph_node.properties['name'] =="The Art of War"
Properties: {'title': 'The Art of War', 'author': 'Sun Tzu', 'name': 'The Art of War'}
# Domain node with 'text' field (truncated to 50 chars)class Quote(DomainNode): text: strquote = Quote(text="This is a very long quote that exceeds fifty characters and will be truncated for the name field.")graph_node = quote.to_graph_node()print(f"Name (truncated): '{graph_node.properties['name']}'")assertlen(graph_node.properties['name']) ==50
Name (truncated): 'This is a very long quote that exceeds fifty chara'