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 7037a81
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 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,10 @@ function dataProvider(
options: {
body,
method: updateHttpMethod,
headers:
updateHttpMethod === 'PATCH'
? { 'content-type': 'application/merge-patch+json' }
: {},
},
url,
}));
Expand Down

0 comments on commit 7037a81

Please sign in to comment.