@@ -22,11 +22,11 @@ interface IQuery {
22
22
23
23
const Context = createContext < IGraphqlBatcher | undefined > ( undefined ) ;
24
24
25
- const executor : AsyncExecutor = async ( { document, variables, extensions } ) => {
25
+ const fetch = async ( url , document , variables ) => {
26
26
try {
27
27
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
28
//@ts -ignore
29
- const result = request ( extensions . url , document , variables ) . then ( ( res ) => ( {
29
+ const result = request ( url , document , variables ) . then ( ( res ) => ( {
30
30
data : res ,
31
31
} ) ) as Promise < ExecutionResult > ;
32
32
@@ -38,12 +38,29 @@ const executor: AsyncExecutor = async ({ document, variables, extensions }) => {
38
38
}
39
39
} ;
40
40
41
- const batchExec = createBatchingExecutor ( executor ) ;
41
+ const coreExecutor : AsyncExecutor = async ( { document, variables } ) => {
42
+ return fetch ( getGraphqlUrl ( false ) , document , variables ) ;
43
+ } ;
44
+
45
+ const dtrExecutor : AsyncExecutor = async ( { document, variables } ) => {
46
+ return fetch ( getGraphqlUrl ( true ) , document , variables ) ;
47
+ } ;
48
+
49
+ const coreBatchExec = createBatchingExecutor ( coreExecutor ) ;
50
+ const dtrBatchExec = createBatchingExecutor ( dtrExecutor ) ;
42
51
43
52
const fetcher = async ( queries : IQuery [ ] ) => {
44
53
const batchdata = await Promise . all (
45
- queries . map ( ( { document, variables, isDisputeTemplate, chainId } ) =>
46
- batchExec ( { document, variables, extensions : { url : getGraphqlUrl ( isDisputeTemplate ?? false , chainId ) } } )
54
+ queries . map ( ( { document, variables, isDisputeTemplate } ) =>
55
+ isDisputeTemplate
56
+ ? dtrBatchExec ( {
57
+ document,
58
+ variables,
59
+ } )
60
+ : coreBatchExec ( {
61
+ document,
62
+ variables,
63
+ } )
47
64
)
48
65
) ;
49
66
0 commit comments