Skip to content

Commit

Permalink
fix: use patch by default
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Nov 8, 2024
1 parent b89e124 commit 17749a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function normalizeHydraKey(json: JsonLdObj, key: string): JsonLdObj {
* GET_LIST => GET http://my.api.url/posts
* GET_MANY => GET http://my.api.url/posts/123, GET http://my.api.url/posts/456, GET http://my.api.url/posts/789
* GET_ONE => GET http://my.api.url/posts/123
* UPDATE => PUT http://my.api.url/posts/123
* UPDATE => PATCH http://my.api.url/posts/123
*/
function dataProvider(
factoryParams: HydraDataProviderFactoryParams,
Expand Down Expand Up @@ -366,7 +366,7 @@ function dataProvider(
if (typeof params.meta === 'object') {
extraInformation = params.meta;
}
const updateHttpMethod = extraInformation.hasFileField ? 'POST' : 'PUT';
const updateHttpMethod = extraInformation.hasFileField ? 'POST' : 'PATCH';

switch (type) {
case CREATE:
Expand Down Expand Up @@ -488,6 +488,7 @@ function dataProvider(
options: {
body,
method: updateHttpMethod,
headers: updateHttpMethod === 'PATCH' ? { 'content-type': 'application/merge-patch+json' } : {}

Check failure on line 491 in src/hydra/dataProvider.ts

View workflow job for this annotation

GitHub Actions / Continuous integration

Replace `·updateHttpMethod·===·'PATCH'·?·{·'content-type':·'application/merge-patch+json'·}·:·{}` with `⏎··············updateHttpMethod·===·'PATCH'⏎················?·{·'content-type':·'application/merge-patch+json'·}⏎················:·{},`
},
url,
}));
Expand Down

0 comments on commit 17749a4

Please sign in to comment.