From 784c3b595ad5f4cef63ef62de3a7d552363f7a43 Mon Sep 17 00:00:00 2001 From: David Barrat Date: Wed, 3 Jan 2024 00:22:04 +0100 Subject: [PATCH] add no cache header option --- .changeset/dry-gifts-smash.md | 5 +++++ packages/core/src/handlers/hydra.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/dry-gifts-smash.md diff --git a/.changeset/dry-gifts-smash.md b/.changeset/dry-gifts-smash.md new file mode 100644 index 0000000..c80672a --- /dev/null +++ b/.changeset/dry-gifts-smash.md @@ -0,0 +1,5 @@ +--- +"@authdog/hydra-core": patch +--- + +add no-cache header option diff --git a/packages/core/src/handlers/hydra.ts b/packages/core/src/handlers/hydra.ts index 95a8545..22eb1fa 100644 --- a/packages/core/src/handlers/hydra.ts +++ b/packages/core/src/handlers/hydra.ts @@ -34,6 +34,8 @@ export const HydraHandler = async (req, env, ctx): Promise => { req.headers.get("x-cluster-client-ip") || req.headers.get("x-forwarded"); + const skipCache = req.headers.get("x-hydra-skip-cache") === "true"; + const facetId = ip || "localhost"; // TODO: extend to more facets combinations const defaultRateLimitingBudget = hydraConfig.rateLimiting.default.budget; let remainingRateBudget = -1; @@ -50,7 +52,9 @@ export const HydraHandler = async (req, env, ctx): Promise => { let extractedQueries = []; - if (isIntrospection) { + const directQuery = isIntrospection || skipCache; + + if (directQuery) { return await GraphQLHandler(req, env, ctx); }