1
1
import { useQuery } from "@tanstack/react-query" ;
2
-
3
2
import { useGraphqlBatcher } from "context/GraphqlBatcher" ;
4
- import { isUndefined } from "utils/index" ;
5
-
6
3
import { graphql } from "src/graphql" ;
7
4
import { JurorsByCoherenceScoreQuery } from "src/graphql/graphql" ;
8
- export type { JurorsByCoherenceScoreQuery } ;
9
5
10
6
const jurorsByCoherenceScoreQuery = graphql ( `
11
- query JurorsByCoherenceScore($skip: Int, $first: Int, $orderBy: User_orderBy, $orderDirection: OrderDirection) {
7
+ query JurorsByCoherenceScore(
8
+ $skip: Int
9
+ $first: Int
10
+ $orderBy: User_orderBy
11
+ $orderDirection: OrderDirection
12
+ $search: String
13
+ ) {
12
14
users(
13
15
first: $first
14
16
skip: $skip
15
17
orderBy: $orderBy
16
18
orderDirection: $orderDirection
17
- where: { totalResolvedVotes_gt: 0 }
19
+ where: { totalResolvedVotes_gt: 0, userAddress_contains: $search }
18
20
) {
19
21
id
20
22
coherenceScore
@@ -25,26 +27,23 @@ const jurorsByCoherenceScoreQuery = graphql(`
25
27
}
26
28
` ) ;
27
29
28
- export const useJurorsByCoherenceScore = ( skip = 0 , first = 20 , orderBy : string , orderDirection : string ) => {
29
- const isEnabled = ! isUndefined ( first ) ;
30
+ export const useJurorsByCoherenceScore = (
31
+ skip = 0 ,
32
+ first = 20 ,
33
+ orderBy : string ,
34
+ orderDirection : string ,
35
+ search = ""
36
+ ) => {
30
37
const { graphqlBatcher } = useGraphqlBatcher ( ) ;
31
38
32
39
return useQuery < JurorsByCoherenceScoreQuery > ( {
33
- queryKey : [ `JurorsByCoherenceScore` , skip , first , orderBy , orderDirection ] ,
34
- enabled : isEnabled ,
40
+ queryKey : [ "JurorsByCoherenceScore" , skip , first , orderBy , orderDirection , search ] ,
35
41
staleTime : Infinity ,
36
42
queryFn : async ( ) =>
37
- isEnabled
38
- ? await graphqlBatcher . fetch ( {
39
- id : crypto . randomUUID ( ) ,
40
- document : jurorsByCoherenceScoreQuery ,
41
- variables : {
42
- skip,
43
- first,
44
- orderBy,
45
- orderDirection,
46
- } ,
47
- } )
48
- : undefined ,
43
+ await graphqlBatcher . fetch ( {
44
+ id : crypto . randomUUID ( ) ,
45
+ document : jurorsByCoherenceScoreQuery ,
46
+ variables : { skip, first, orderBy, orderDirection, search } ,
47
+ } ) ,
49
48
} ) ;
50
49
} ;
0 commit comments