MCPcopy Index your code
hub / github.com/webiny/webiny-js / createRequestBody

Function createRequestBody

packages/handler-graphql/src/createRequestBody.ts:20–33  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

18const schema = zod.union([requestBodySchema, zod.array(requestBodySchema)]);
19
20export const createRequestBody = (input: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {
21 const body = typeof input === "string" ? JSON.parse(input) : input;
22
23 const result = schema.safeParse(body);
24 if (!result.success) {
25 const error = createZodError(result.error);
26 throw new WebinyError({
27 message: "Invalid GraphQL request! Check your query and variables.",
28 code: "GRAPHQL_REQUEST_INVALID",
29 data: error.data
30 });
31 }
32 return result.data;
33};

Callers 3

handleRequestFunction · 0.50

Calls 2

createZodErrorFunction · 0.85
parseMethod · 0.65

Tested by

no test coverage detected