From 70ff9e9c6aed1ebd34866870e85c3a93205b00c3 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:45:51 -0400 Subject: [PATCH] feat: add subquery hashing --- packages/call-apis/package.json | 5 +++-- packages/call-apis/src/queries/subquery.ts | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/call-apis/package.json b/packages/call-apis/package.json index 60db83a..94f3159 100644 --- a/packages/call-apis/package.json +++ b/packages/call-apis/package.json @@ -34,14 +34,15 @@ "dependencies": { "@biothings-explorer/api-response-transform": "workspace:../api-response-transform", "@biothings-explorer/smartapi-kg": "workspace:../smartapi-kg", - "biomedical_id_resolver": "workspace:../biomedical_id_resolver", "@biothings-explorer/utils": "workspace:../utils", "@sentry/node": "^7.74.1", "axios": "^0.21.4", "axios-retry": "^3.8.1", + "biomedical_id_resolver": "workspace:../biomedical_id_resolver", "debug": "^4.3.4", "husky": "^4.3.8", - "nunjucks": "^3.2.4" + "json-stable-stringify": "^1.1.1", + "nunjucks": "^3.2.4", }, "devDependencies": { "@commitlint/cli": "^11.0.0", diff --git a/packages/call-apis/src/queries/subquery.ts b/packages/call-apis/src/queries/subquery.ts index 36c7ef8..668fcba 100644 --- a/packages/call-apis/src/queries/subquery.ts +++ b/packages/call-apis/src/queries/subquery.ts @@ -94,6 +94,12 @@ export default class Subquery { } } + get hash(): string { + return crypto + .createHash("md5") + .update(stringify(this.constructAxiosRequestConfig())) + .digest("hex"); + } /** * Construct the request config for Axios reqeust.