File tree Expand file tree Collapse file tree
api-headless-cms/__tests__/testHelpers Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments