Giter VIP home page Giter VIP logo

Comments (4)

seantleonard avatar seantleonard commented on July 22, 2024 1

Proposed design:

Microsoft REST Guidelines

Implementation adheres to Microsoft REST Guidelines

Creating resources via PATCH (UPSERT semantics) Link

"Because PUT is defined as a complete replacement of the content, it is dangerous for clients to use PUT to modify data. Clients that do not understand (and hence ignore) properties on a resource are not likely to provide them on a PUT when trying to update a resource, hence such properties could be inadvertently removed. Services MAY optionally support PUT to update existing resources, but if they do they MUST use replacement semantics (that is, after the PUT, the resource's properties MUST match what was provided in the request, including deleting any server properties that were not provided)."

Sample Requests

  1. PUT https://localhost:5001/books/id/1
  • If object exists:

JSON Response: HTTP 202 Accepted
JSON Body: Operation-Location:<resourceURI>

  • If object does not exist:

JSON Response: HTTP 201 Created
JSON Body: Operation-Location:<resourceURI>

Implementation Notes

Built to handle both inserts and updating an item with only the parameters included in the request,
while deleting/nulling out fields not included in the request.

Tests

UpsertById

  • PUT operation on existing item updates the item with declared parameters, nulling out non-included parameters (that are nullable per schema).
  • PUT operation on non-existent item, inserts that item with declared parameters.
    • (Neg) if autogenerated parameter defined in request body -> 400 Bad Request

from data-api-builder.

seantleonard avatar seantleonard commented on July 22, 2024

Prior to picking this up, please check status of #23 as mutation base elements to be added by PG team (Jelte/Gledis) first then we can iterate. Avoid duplication of work as base elements similar across REST/GraphQL

from data-api-builder.

seantleonard avatar seantleonard commented on July 22, 2024

Find item by id -> update structure. otherwise insert

from data-api-builder.

Aniruddh25 avatar Aniruddh25 commented on July 22, 2024

This represents Case 2 of the PUT behavior outlined in the project-hawaii issue: https://github.com/Azure/project-hawaii/issues/50

from data-api-builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.