From 2484c8dee135987b5cf4fda86fdb0a9c452331da Mon Sep 17 00:00:00 2001 From: David Barrat Date: Sat, 6 Jan 2024 01:28:27 +0100 Subject: [PATCH] feat: enabling __typename in response stream --- .changeset/real-news-lay.md | 5 +++++ packages/core/src/handlers/hydra.ts | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/real-news-lay.md diff --git a/.changeset/real-news-lay.md b/.changeset/real-news-lay.md new file mode 100644 index 0000000..06a2189 --- /dev/null +++ b/.changeset/real-news-lay.md @@ -0,0 +1,5 @@ +--- +"@authdog/hydra-core": patch +--- + +enabling \_\_typename in response stream diff --git a/packages/core/src/handlers/hydra.ts b/packages/core/src/handlers/hydra.ts index 5615f68..de5729c 100644 --- a/packages/core/src/handlers/hydra.ts +++ b/packages/core/src/handlers/hydra.ts @@ -279,8 +279,6 @@ export const HydraHandler = async (req, env, ctx): Promise => { 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(); @@ -443,9 +441,10 @@ export const HydraHandler = async (req, env, ctx): Promise => { } 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",