ENG-1984 Define cross-app schema contracts#1193
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
562c561 to
f1e49e1
Compare
| export type CrossAppRelationTripleSchema = CrossAppBase & { | ||
| label: string; | ||
| complement: string; | ||
| relation?: Ref | CrossAppRelationTypeSchema; | ||
| sourceType: Ref; | ||
| destinationType: Ref; | ||
| }; |
There was a problem hiding this comment.
Data consistency issue: CrossAppRelationTripleSchema has redundant label and complement fields that conflict with the optional relation field of type CrossAppRelationTypeSchema, which also contains label and complement. This creates ambiguity about which values should be authoritative.
When relation is provided, there are now two sources of truth for label and complement, which can diverge and cause data inconsistency. Consider one of these approaches:
// Option 1: Remove redundant fields, require relation reference
export type CrossAppRelationTripleSchema = CrossAppBase & {
relation: Ref | CrossAppRelationTypeSchema;
sourceType: Ref;
destinationType: Ref;
};
// Option 2: Make fields conditional based on relation presence
export type CrossAppRelationTripleSchema = CrossAppBase & (
| { relation: Ref | CrossAppRelationTypeSchema; sourceType: Ref; destinationType: Ref; }
| { label: string; complement: string; sourceType: Ref; destinationType: Ref; }
);| export type CrossAppRelationTripleSchema = CrossAppBase & { | |
| label: string; | |
| complement: string; | |
| relation?: Ref | CrossAppRelationTypeSchema; | |
| sourceType: Ref; | |
| destinationType: Ref; | |
| }; | |
| export type CrossAppRelationTripleSchema = CrossAppBase & ( | |
| | { | |
| relation: Ref | CrossAppRelationTypeSchema; | |
| sourceType: Ref; | |
| destinationType: Ref; | |
| } | |
| | { | |
| label: string; | |
| complement: string; | |
| sourceType: Ref; | |
| destinationType: Ref; | |
| } | |
| ); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
https://linear.app/discourse-graphs/issue/ENG-1984/define-cross-app-schema-contracts