Skip to content

Make RelationType.set_relates return the created role #566

Open
@james-whiteside

Description

@james-whiteside

Problem to Solve

Currently, RelationType.set_relates returns Promise[None]. This is pretty inconvenient, as a lot of the time we then want to perform further operations on the newly created role. Unlike the put methods for creating thing types, there is no parallel for roles, so they need to be gotten with RelationType.get_relates to continue operating on them like so:

message = transaction.concepts.put_relation_type("message").resolve()
message.set_relates(transaction, "sender").resolve()
message.set_relates(transaction, "recipient").resolve()
message_sender = response.get_relates(transaction, "sender").resolve()
message_recipient = response.get_relates(transaction, "recipient").resolve()

Proposed Solution

Make RelationType.set_relates return Promise[RoleType] instead of Promise[None], like so:

message = transaction.concepts.put_relation_type("message").resolve()
message_sender = message.set_relates(transaction, "sender").resolve()
message_recipient = message.set_relates(transaction, "recipient").resolve()

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions