Skip to content

Commit 59ea6b9

Browse files
committed
fix(handler-aws): remove default body
1 parent d5cdf98 commit 59ea6b9

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

packages/api-headless-cms/__tests__/testHelpers/useGraphQLHandler.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,23 @@ export const useGraphQLHandler = (params: GraphQLHandlerParams = {}) => {
9595
headers = {},
9696
...rest
9797
}: InvokeParams): Promise<[IBaseGraphQLResponse<T>, any]> => {
98-
const response = await handler(
99-
{
100-
/**
101-
* If no path defined, use /graphql as we want to make request to main api
102-
*/
103-
path: path ? `/cms/${path}` : "/graphql",
104-
httpMethod,
105-
headers: {
106-
["x-tenant"]: "root",
107-
["Content-Type"]: "application/json",
108-
...headers
109-
},
110-
body: JSON.stringify(body),
111-
...rest
112-
} as unknown as APIGatewayEvent,
113-
{} as unknown as LambdaContext
114-
);
98+
const event = {
99+
/**
100+
* If no path defined, use /graphql as we want to make request to main api
101+
*/
102+
path: path ? `/cms/${path}` : "/graphql",
103+
httpMethod,
104+
headers: {
105+
["x-tenant"]: "root",
106+
["content-type"]: "application/json",
107+
...headers
108+
},
109+
...rest
110+
} as unknown as APIGatewayEvent;
111+
if (body) {
112+
event.body = JSON.stringify(body);
113+
}
114+
const response = await handler(event, {} as unknown as LambdaContext);
115115
// The first element is the response body, and the second is the raw response.
116116
return [JSON.parse(response.body || "{}"), response];
117117
};

packages/handler-aws/src/gateway/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ const attachRequiredProperties = (event: APIGatewayEvent): void => {
4949
*/
5050
if (!contentType) {
5151
event.headers["content-type"] = [defaultContentType, `charset=${defaultCharset}`].join(";");
52-
event.body = "{}";
53-
} else if (!event.body && contentType.startsWith(defaultContentType)) {
54-
event.body = "{}";
5552
}
5653
};
5754

0 commit comments

Comments
 (0)