From 9421da3ba697ba3bfae4a7070ac9ebc0bad2a9ab Mon Sep 17 00:00:00 2001 From: artlu99 Date: Fri, 1 Nov 2024 19:49:55 -0400 Subject: [PATCH] try urql instead of graphql-request --- functions/getSassyHashes/index.ts | 13 +++++--- package.json | 2 +- yarn.lock | 51 ++++++++++++++++++------------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/functions/getSassyHashes/index.ts b/functions/getSassyHashes/index.ts index d3c1755..3fcb398 100644 --- a/functions/getSassyHashes/index.ts +++ b/functions/getSassyHashes/index.ts @@ -1,4 +1,5 @@ -import { GraphQLClient, gql } from 'graphql-request'; +import { Client, fetchExchange, gql } from '@urql/core'; + import { Env } from '../common'; interface SassyHash { @@ -8,7 +9,7 @@ interface SassyHash { isDecrypted: boolean; } interface SassyHashGraphQLResponse { - data: { getTextByCastHash: SassyHash }; + getTextByCastHash: SassyHash; } interface SassyHashRequest { fid: number; @@ -16,12 +17,14 @@ interface SassyHashRequest { } const fetchSassyHashExpensiveApi = async (fid: number, castHash: string, env: Env) => { - const graphQLClient = new GraphQLClient(env.SASSYHASH_API, { - headers: { authorization: `Bearer ${env.WHISTLES_BEARER_TOKEN}` }, + const client = new Client({ + url: env.SASSYHASH_API, + exchanges: [fetchExchange], + fetchOptions: { headers: { authorization: `Bearer ${env.WHISTLES_BEARER_TOKEN}` } }, }); try { - const res = await graphQLClient.request( + const res = await client.query( gql` query getTextByCastHash($castHash: String!, $viewerFid: Int!) { getTextByCastHash(castHash: $castHash, viewerFid: $viewerFid) { diff --git a/package.json b/package.json index 11c3784..677e687 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@tanstack/react-query": "^5.45.0", "@tanstack/react-query-persist-client": "^5.45.0", "@upstash/redis": "^1.31.4", + "@urql/core": "^5.0.8", "antd": "^4.22.4", "antd-mask-input": "^2.0.7", "antd-style": "^3.6.2", @@ -27,7 +28,6 @@ "echarts-for-react": "^3.0.1", "elt-react-credit-cards": "^0.0.1", "exponential-backoff": "^3.1.1", - "graphql-request": "^7.1.1", "i18next": "^20.4.0", "idb-keyval": "^6.2.1", "lucide-react": "^0.394.0", diff --git a/yarn.lock b/yarn.lock index 092ca3e..47d7852 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,18 @@ __metadata: version: 5 cacheKey: 8 +"@0no-co/graphql.web@npm:^1.0.5": + version: 1.0.10 + resolution: "@0no-co/graphql.web@npm:1.0.10" + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 + peerDependenciesMeta: + graphql: + optional: true + checksum: d271a3cbf82ac4691d695053a385a1682c5792c7f3c01fa254c0616fd727297f3d19d3a32420dfe701aafd25dde8f093c8a6380de0ff35cce2790539ecbbf8e0 + languageName: node + linkType: hard + "@adraffy/ens-normalize@npm:1.10.0": version: 1.10.0 resolution: "@adraffy/ens-normalize@npm:1.10.0" @@ -3284,15 +3296,6 @@ __metadata: languageName: node linkType: hard -"@graphql-typed-document-node/core@npm:^3.2.0": - version: 3.2.0 - resolution: "@graphql-typed-document-node/core@npm:3.2.0" - peerDependencies: - graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 - checksum: fa44443accd28c8cf4cb96aaaf39d144a22e8b091b13366843f4e97d19c7bfeaf609ce3c7603a4aeffe385081eaf8ea245d078633a7324c11c5ec4b2011bb76d - languageName: node - linkType: hard - "@grpc/grpc-js@npm:~1.8.21": version: 1.8.22 resolution: "@grpc/grpc-js@npm:1.8.22" @@ -5052,6 +5055,16 @@ __metadata: languageName: node linkType: hard +"@urql/core@npm:^5.0.8": + version: 5.0.8 + resolution: "@urql/core@npm:5.0.8" + dependencies: + "@0no-co/graphql.web": ^1.0.5 + wonka: ^6.3.2 + checksum: 2e0e1791e49585c5a28d24640d8585b8ff663e2feda73ea344a9ab213ca760466293ea16fa9a7bbc104c1ddeb1d61d320a45fda84a44f3b124b06767323df4c6 + languageName: node + linkType: hard + "@vitejs/plugin-react@npm:^4.3.0": version: 4.3.0 resolution: "@vitejs/plugin-react@npm:4.3.0" @@ -5847,6 +5860,7 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.10.0 "@typescript-eslint/parser": ^5.8.0 "@upstash/redis": ^1.31.4 + "@urql/core": ^5.0.8 "@vitejs/plugin-react": ^4.3.0 antd: ^4.22.4 antd-mask-input: ^2.0.7 @@ -5865,7 +5879,6 @@ __metadata: eslint-plugin-react: ^7.24.0 eslint-plugin-react-hooks: ^4.3.0 exponential-backoff: ^3.1.1 - graphql-request: ^7.1.1 husky: ^9.0.11 i18next: ^20.4.0 idb-keyval: ^6.2.1 @@ -8328,17 +8341,6 @@ __metadata: languageName: node linkType: hard -"graphql-request@npm:^7.1.1": - version: 7.1.1 - resolution: "graphql-request@npm:7.1.1" - dependencies: - "@graphql-typed-document-node/core": ^3.2.0 - peerDependencies: - graphql: 14 - 16 - checksum: b47b310a3c0b701828d268621a81d71864236fc5959f6ab4f9c3b03f6955f92abdbcf444de39f08776ac498895c7d958957a261f1082d448159218ed83da3157 - languageName: node - linkType: hard - "gzip-size@npm:^6.0.0": version: 6.0.0 resolution: "gzip-size@npm:6.0.0" @@ -14724,6 +14726,13 @@ __metadata: languageName: node linkType: hard +"wonka@npm:^6.3.2": + version: 6.3.4 + resolution: "wonka@npm:6.3.4" + checksum: 6bb57955cb2982fb469a7824484e6854b436f89a7f10b6a981348789d88fbc944665771adc4cc404f62416417eb47ab2b8657d898e5301ccd4a53eaac6a10508 + languageName: node + linkType: hard + "word-wrap@npm:^1.2.5": version: 1.2.5 resolution: "word-wrap@npm:1.2.5"