Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
854 stars 177 forks source link

Database Query Generation Design Doc - Multiple Create #1887

Closed severussundar closed 7 months ago

severussundar commented 10 months ago

Write and check-in a design doc for the query generation part of Nested Inserts functionality

seantleonard commented 10 months ago

Depends on design finalization and answered questions for schema generation (update this text if necessary)

seantleonard commented 8 months ago
seantleonard commented 8 months ago

Schedule design discussion before .11 close.

severussundar commented 7 months ago

Current Status:

Book Table

image

Publisher Table image

Authors Table image

Book Author Link Table image

Reviews Table image

severussundar commented 7 months ago

Scenarios Completed:

  1. Point mutation operation ~ createbook
  2. Multiple mutation operation ~ createbooks

For both of these operations, the below aspects of the feature are completed.

  1. Successful database query generation involving nested entities with varying depths.
    • All relationship types are completed: 1:1, 1: N, N:1, M: N (including linking table insertion)
  2. Transactional aspect of the feature - Successful rollback of all created items when there is any failure
  3. Mappings - When the column name is exposed through a different name for graphQL operations
  4. PK being Auto-generated vs Non-Auto generated (at any level)
  5. Selection set resolution
    • Aspects like pagination: nextCursor, hasNext fields etc. are also completed
  6. Incorporating database policies when defined

    • create policy: Successfully incorporated during the creation of a new record. When any of the insert fails due to database policy, all the inserts for the whole nested insert operation are rolled back successfully.
    • read policy: Successfully incorporated during the selection set resolution phase. When a record does not satisfy the read database policy defined, it will not be returned in the response.

    Things pending:

    1. Scenarios where the relationship is defined only at the config file level (no FK constraints defined)
    2. Handling the scenario where relationship is defined at both the config level and database level - Need to write logic to throw appropriate errors.
seantleonard commented 7 months ago

@severussundar Do the pending items have to implemented in the same changeset? can they be a part of follow up PRs?

severussundar commented 7 months ago

Hey Sean, they will be implemented in a separate PR.