File tree Expand file tree Collapse file tree 1 file changed +30
-17
lines changed Expand file tree Collapse file tree 1 file changed +30
-17
lines changed Original file line number Diff line number Diff line change
1
+ import type { ResultOf } from 'gql.tada'
2
+ import nftListWithSearch from '~/queries/subsquid/general/nftListWithSearch'
3
+
1
4
export default function useSearchNfts ( {
2
5
search,
3
6
first = 10 ,
@@ -10,26 +13,36 @@ export default function useSearchNfts({
10
13
const { client } = usePrefix ( )
11
14
const chainPrefix = prefix || client . value
12
15
13
- const { data, refetch, loading } = useGraphql ( {
14
- queryPrefix : client . value ,
15
- clientName : chainPrefix ,
16
- queryName : 'nftListWithSearch' ,
17
- variables : {
18
- first,
19
- search,
20
- orderBy,
21
- denyList,
22
- offset,
23
- } ,
24
- options : {
25
- fetchPolicy : 'cache-first' ,
26
- } ,
27
- disabled : computed ( ( ) => ! immediate ) ,
28
- } )
16
+ const { $apolloClient } = useNuxtApp ( )
17
+ const data = ref < ResultOf < typeof nftListWithSearch > > ( )
18
+ const loading = ref ( true )
19
+
20
+ const fetchSearch = ( ) => {
21
+ $apolloClient . query ( {
22
+ query : nftListWithSearch ,
23
+ variables : {
24
+ first,
25
+ search,
26
+ orderBy : [ orderBy ] ,
27
+ denyList,
28
+ offset,
29
+ } ,
30
+ context : {
31
+ endpoint : chainPrefix ,
32
+ } ,
33
+ } ) . then ( ( res ) => {
34
+ data . value = res . data
35
+ loading . value = false
36
+ } )
37
+ }
38
+
39
+ if ( immediate ) {
40
+ fetchSearch ( )
41
+ }
29
42
30
43
return {
31
44
data,
32
- refetch,
45
+ refetch : fetchSearch ,
33
46
loading,
34
47
}
35
48
}
You can’t perform that action at this time.
0 commit comments