-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What would you like to be added?
Currently, the ProjectionType makes it easy to list explicitly defined relationships. However, there is no straightforward way to resolve implicit relationships between entities.
Consider the following entity definitions:
CartItem
name: CartItem
summary: Represents a cart item
description: Represents a cart item
schema:
type: object
properties:
orderId:
type: string
productId:
type: string
product:
type: object
quantity:
type: number
required: [orderId, productId, quantity]
triggers:
create:
- event:
type: io.cloud-shapes.examples.events.cart-item.created.v1
source: https://examples.cloud-shapes.io
correlation:
attribute: subject
state: '${ .data }'
relationships:
- type: one-to-one
target: Product
key: productId
path: productOrder
name: Order
summary: Represents a sales order
description: Represents a sales order
schema:
type: object
properties:
status:
type: string
items:
type: array
required: [status]
triggers:
create:
- event:
type: io.cloud-shapes.examples.events.order.created.v1
source: https://examples.cloud-shapes.io
correlation:
attribute: subject
state: '${ .data }'
relationships:
- type: one-to-many
target: CartItem
key: orderId
path: itemsThe CartItem entity explicitly defines a relationship with Product.
However, CartItem also has an implicit relationship with Order, but this is not directly defined in its relationships.
There should be an easy way to resolve such implicit relationships.
Proposal(s):
Either add implicit relationships in the ProjectionType.Relationships, with a flag to distinguish the explicit and implicit ones.
Or add an "ImplicitRelationships" property to ProjectionType.
Alternative(s):
As an alternative, we can query the API of ProjectionTypes to find projection types where the relationships have a target that corresponds to the entity in question. For example, in the case of CartItem, we can look for projection types where a relationship's target is CartItem. This allows us to infer implicit relationships without them being explicitly defined within the entity itself.
Additional info:
No response
Community Notes
- Please vote by adding a 👍 reaction to the feature to help us prioritize.
- If you are interested to work on this feature, please leave a comment.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status