From 8057603ee05fb5555d0ffad427dcb97f1d122050 Mon Sep 17 00:00:00 2001 From: Roger Tuan <11964962+arcataroger@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:12:57 -0700 Subject: [PATCH 1/2] Update serialize.ts - Fix body.type vs options.type --- packages/rest-client-utils/src/serialize.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rest-client-utils/src/serialize.ts b/packages/rest-client-utils/src/serialize.ts index 1604aad..fbd03ee 100644 --- a/packages/rest-client-utils/src/serialize.ts +++ b/packages/rest-client-utils/src/serialize.ts @@ -116,7 +116,7 @@ export function serializeRequestBody( return { data: { ...(id || options.id ? { id: id || options.id } : {}), - type: type || options.type, + type: options.type, // If a body.type is passed in, it should go in data.attributes. Only options.type should be here at the root. ...(Object.keys(attributes).length > 0 ? { attributes } : {}), ...(Object.keys(relationships).length > 0 ? { relationships } : {}), ...(meta ? { meta } : {}), From f17465b6e3fbe5571d230ea811a3ce7dbe25117e Mon Sep 17 00:00:00 2001 From: Roger Tuan <11964962+arcataroger@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:21:40 -0700 Subject: [PATCH 2/2] Remove `type` from body destruc --- packages/rest-client-utils/src/serialize.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rest-client-utils/src/serialize.ts b/packages/rest-client-utils/src/serialize.ts index fbd03ee..1c0f478 100644 --- a/packages/rest-client-utils/src/serialize.ts +++ b/packages/rest-client-utils/src/serialize.ts @@ -49,7 +49,7 @@ export function serializeRequestBody( } as unknown as T; } - const { id, type, meta, ...otherProperties } = body as any; + const { id, meta, ...otherProperties } = body as any; const attributes: Record = {}; const relationships: Record = {};