Skip to content

Commit 5841574

Browse files
committed
feat(web): graphql refactor, small issue with query
1 parent 54b7570 commit 5841574

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

web/codegen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { CodegenConfig } from "@graphql-codegen/cli";
2-
import { graphqlUrl } from "utils/graphqlQueryFnHelper";
2+
import { getGraphqlUrl } from "utils/getGraphqlUrl";
33

44
const config: CodegenConfig = {
55
overwrite: true,
6-
schema: [graphqlUrl()],
6+
schema: [getGraphqlUrl()],
77
documents: "./src/hooks/queries/*.ts",
88
generates: {
99
"./src/graphql/": {

web/src/context/GraphqlBatcher.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { arbitrumSepolia } from "wagmi/chains";
33
import { request } from "graphql-request";
44
import { create, windowedFiniteBatchScheduler, Batcher } from "@yornaath/batshit";
55
import { TypedDocumentNode } from "@graphql-typed-document-node/core";
6-
import { getGraphqlUrl } from "utils/getGraphqlUrl";
76
import { debounceErrorToast } from "utils/debounceErrorToast";
7+
import { getGraphqlUrl } from "utils/getGraphqlUrl";
88

99
interface IGraphqlBatcher {
1010
graphqlBatcher: Batcher<any, IQuery>;
@@ -14,14 +14,13 @@ interface IQuery {
1414
id: string;
1515
document: TypedDocumentNode<any, any>;
1616
variables: Record<string, any>;
17-
isDisputeTemplate?: boolean;
1817
chainId?: number;
1918
}
2019

2120
const Context = createContext<IGraphqlBatcher | undefined>(undefined);
2221

2322
const fetcher = async (queries: IQuery[]) => {
24-
const promises = queries.map(async ({ id, document, variables, isDisputeTemplate, chainId }) => {
23+
const promises = queries.map(async ({ id, document, variables, chainId }) => {
2524
const url = getGraphqlUrl(chainId ?? arbitrumSepolia.id);
2625
try {
2726
return request(url, document, variables).then((result) => ({ id, result }));

web/src/context/RefetchOnBlock.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const useRefetchOnBlock = () => {
88

99
useEffect(() => {
1010
const unwatch = publicClient?.watchBlocks({
11-
onBlock: () => {
12-
queryClient.invalidateQueries(["refetchOnBlock"]);
11+
onBlock: (block) => {
12+
if (block.number % BigInt(10) === BigInt(0)) queryClient.invalidateQueries(["refetchOnBlock"]);
1313
},
1414
});
1515
return () => unwatch?.();

web/src/hooks/queries/useItemDetailsQuery.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ const itemDetailsQuery = graphql(`
99
item(id: $itemID) {
1010
status
1111
disputed
12-
latestChallenger
13-
latestRequester
12+
latestChallenger {
13+
id
14+
}
15+
latestRequester {
16+
id
17+
}
1418
registryAddress
1519
props {
1620
type

web/src/utils/graphqlQueryFnHelper.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)