Skip to content

Commit

Permalink
feat: enabling __typename in response stream
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrrt committed Jan 6, 2024
1 parent 320f085 commit 2484c8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-news-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@authdog/hydra-core": patch
---

enabling \_\_typename in response stream
7 changes: 3 additions & 4 deletions packages/core/src/handlers/hydra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ export const HydraHandler = async (req, env, ctx): Promise<Response> => {
payload = await GraphQLHandler(newRequest, env, ctx);

if (isMutation) {
console.log("isMutation", isMutation);

const { data } = await payload.clone().json();
const aggregatedIds = aggregateTypesWithIds(data);
const allKeys = await kvNamespace.list();
Expand Down Expand Up @@ -443,9 +441,10 @@ export const HydraHandler = async (req, env, ctx): Promise<Response> => {
}

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

payload = new Response(JSON.stringify(finalPayload), {
payload = new Response(JSON.stringify(streamData), {
status: 200,
headers: {
"content-type": "application/json;charset=UTF-8",
Expand Down

0 comments on commit 2484c8d

Please sign in to comment.