Skip to content

Add patch method using the PATCH HTTP verb#150

Open
jdeniau wants to merge 1 commit into
mainfrom
feat/patch-method
Open

Add patch method using the PATCH HTTP verb#150
jdeniau wants to merge 1 commit into
mainfrom
feat/patch-method

Conversation

@jdeniau

@jdeniau jdeniau commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Adds a patch method to AbstractClient, available on every repository.

It behaves exactly like update (same arguments, same UnitOfWork dirty-field handling — only dirty fields are sent) but issues a PATCH request instead of PUT.

sdk.getRepository('products').patch(entity);

Implementation

  • Factored the shared body of update into a private _update(method, …) helper.
  • update() delegates to _update('PUT', …), patch() delegates to _update('PATCH', …).

Tests

  • allow passing request params in patch — checks request params forwarding and that the PATCH verb is used.
  • patching data with unit of work — checks the dirty-diff works with PATCH (only { status: 'foo' } is sent, then {} when nothing changed).

All AbstractClient tests and yarn lint pass.

Note

The content type stays application/json (same as update). If your API expects application/merge-patch+json, pass it via requestParams.headers.

`patch` behaves like `update` (same arguments and UnitOfWork dirty-field
handling) but sends a PATCH request instead of PUT. The shared logic is
factored into a private `_update` method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant