Skip to content

Commit

Permalink
cleanup response
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrrt committed Jan 6, 2024
1 parent df56e8e commit c391589
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-bulldogs-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@authdog/hydra-core": patch
---

cleanup response
10 changes: 5 additions & 5 deletions packages/core/src/handlers/hydra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ export const HydraHandler = async (req, env, ctx): Promise<Response> => {
body: JSON.stringify(newRequestPayload),
});

console.log(JSON.stringify(newRequestPayload, null, 2));

payload = await GraphQLHandler(newRequest, env, ctx);

if (isMutation) {
Expand Down Expand Up @@ -440,18 +442,16 @@ export const HydraHandler = async (req, env, ctx): Promise<Response> => {
await Promise.all(promises);
}

const streamData: any = await readStream(payload?.body?.getReader());
// const streamData: any = await readStream(payload?.body?.getReader());
// removing __typename from response prevents cache invalidation with urql, disable for now
// const finalPayload = removeTypename(JSON.parse(streamData));

payload = new Response(JSON.stringify(streamData), {
return new Response(JSON.stringify(payload), {
status: 200,
headers: {
"content-type": "application/json;charset=UTF-8",
"x-hydra-rate-budget": String(remainingRateBudget),
"x-hydra-rate-threshold": String(defaultRateLimitingBudget),
},
});

return payload;
});;
};

0 comments on commit c391589

Please sign in to comment.