From 4c2d0a917713f69af79ceba44696735220c87913 Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Thu, 18 Dec 2025 08:43:26 -0500 Subject: [PATCH] fix: revert back to using typed documents for GraphQL --- package.json | 1 + pnpm-lock.yaml | 3 +++ src/libs/anilist/anilist-do.ts | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b8f31e..4540a8e 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "@cloudflare/vitest-pool-workers": "^0.10.15", + "@graphql-typed-document-node/core": "^3.2.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/lodash.mapkeys": "^4.6.9", "@types/luxon": "^3.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6388634..6767999 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: "@cloudflare/vitest-pool-workers": specifier: ^0.10.15 version: 0.10.15(@vitest/runner@3.2.4)(@vitest/snapshot@3.2.4)(vitest@3.2.4) + "@graphql-typed-document-node/core": + specifier: ^3.2.0 + version: 3.2.0(graphql@16.12.0) "@trivago/prettier-plugin-sort-imports": specifier: ^4.3.0 version: 4.3.0(prettier@3.7.4) diff --git a/src/libs/anilist/anilist-do.ts b/src/libs/anilist/anilist-do.ts index 50781df..781f9af 100644 --- a/src/libs/anilist/anilist-do.ts +++ b/src/libs/anilist/anilist-do.ts @@ -1,3 +1,4 @@ +import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { DurableObject } from "cloudflare:workers"; import { print } from "graphql"; import { z } from "zod"; @@ -271,7 +272,7 @@ export class AnilistDurableObject extends DurableObject { } async fetchFromAnilist( - queryString: string, + query: TypedDocumentNode, variables: Variables, token?: string | undefined, ): Promise { @@ -285,7 +286,7 @@ export class AnilistDurableObject extends DurableObject { // Use the query passed in, or fallback if needed (though we expect it to be passed) // We print the query to string - // const queryString = print(query); + const queryString = print(query); const response = await fetch(`${this.env.PROXY_URL}/proxy`, { method: "POST",