From 7037a8117e0829d495cb400fb48ef3fd8f0690c8 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 8 Nov 2024 15:38:30 +0100 Subject: [PATCH] fix: use patch by default --- src/hydra/dataProvider.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hydra/dataProvider.ts b/src/hydra/dataProvider.ts index a7efd355..56023248 100644 --- a/src/hydra/dataProvider.ts +++ b/src/hydra/dataProvider.ts @@ -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, @@ -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: @@ -488,6 +488,10 @@ function dataProvider( options: { body, method: updateHttpMethod, + headers: + updateHttpMethod === 'PATCH' + ? { 'content-type': 'application/merge-patch+json' } + : {}, }, url, }));