Azure / Azure/data-api-builder

[Enh]: Support relationships between views (and tables).

Đang mở
#3,079 0 bình luận 2 reaction 2 người được giao Xem trên GitHub

@JerryNixon đang làm issue này rồi.

Từ ngày 23/1/2026.

2.2 enhancement graphql has-pr mssql pgsql mysql
Ngôn ngữ chính
C#
Star
1.5k
Fork
372
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
9

Mô tả

What

Allow entities backed by views to participate in relationships.

Supported combinations
  • view → view
  • view → table
  • table → view

No new configuration syntax. Existing entities.<name>.relationships settings continue to work.

Unlimited combinations
flowchart LR
    Table1
    Table2
    View1
    View2

    Table1 --> Table2
    Table1 --> View1
    View1 --> View2
    View1 --> Table2

[!NOTE]
Stored procedures cannot be related.

Why

Today relationships only work between table entities.

However, DAB already allows relationships to be defined in configuration without requiring database FK constraints. If a relationship can be described using fields in configuration, the engine should be able to generate the join even when the underlying object is a view.

This enables common read models where views shape the data exposed through the API. A view such as SeriesActors can already be exposed as an entity, but it cannot currently participate in relationships.

Example

View → table relationship

Exactly the same syntax as before

"entities": {
  "BooksView": {
    "source": { "object": "dbo.vw_books_details", "type": "view" },
    "relationships": {
      "publisher": {
        "cardinality": "one",
        "target.entity": "Publisher",
        "relationship.fields": [ "publisher_id:id" ]
      }
    }
  }
}
View → view relationship

Exactly the same syntax as table

"relationships": {
  "authors": {
    "cardinality": "many",
    "target.entity": "AuthorsView",
    "relationship.fields": [ "id:book_id" ]
  }
}

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.