@@ -6,15 +6,31 @@ import { actionToCamelCase } from 'common/utilities/strings/strings'
6
6
7
7
const searchSavedItemsQuery = gql `
8
8
query SearchSavedItems(
9
- $term: String!
10
9
$sort: SearchSortInput
11
10
$pagination: PaginationInput
12
- $filter: SearchFilterInput
11
+ $filter: AdvancedSearchFilters
12
+ $queryString: String
13
13
) {
14
14
user {
15
- searchSavedItems(term: $term, sort: $sort, pagination: $pagination, filter: $filter) {
15
+ advancedSearch(
16
+ filter: $filter
17
+ queryString: $queryString
18
+ pagination: $pagination
19
+ sort: $sort
20
+ ) {
21
+ pageInfo {
22
+ hasNextPage
23
+ hasPreviousPage
24
+ startCursor
25
+ endCursor
26
+ }
27
+ totalCount
16
28
edges {
17
29
node {
30
+ searchHighlights {
31
+ fullText
32
+ title
33
+ }
18
34
savedItem {
19
35
url
20
36
_createdAt
@@ -31,13 +47,13 @@ const searchSavedItemsQuery = gql`
31
47
}
32
48
item {
33
49
... on Item {
50
+ givenUrl
51
+ itemId
34
52
isArticle
35
53
hasImage
36
54
hasVideo
37
55
timeToRead
38
56
shareId: id
39
- itemId
40
- givenUrl
41
57
preview {
42
58
...ItemPreview
43
59
}
@@ -46,13 +62,6 @@ const searchSavedItemsQuery = gql`
46
62
}
47
63
}
48
64
}
49
- pageInfo {
50
- hasNextPage
51
- hasPreviousPage
52
- startCursor
53
- endCursor
54
- }
55
- totalCount
56
65
}
57
66
}
58
67
}
@@ -71,15 +80,18 @@ export async function getSavedItemsSearch({
71
80
actionType,
72
81
sortOrder = 'DESC' ,
73
82
pagination,
74
- searchTerm : term
83
+ searchTerm : queryString
75
84
} ) {
76
85
const requestDetails = itemFiltersFromGraph [ actionType ]
77
86
if ( ! requestDetails ) throw new MalformedItemSearchError ( )
78
87
79
88
const { filter, sort } = requestDetails
80
- const variables = { filter : { ...filter } , sort : { ...sort , sortOrder } , term, pagination }
81
- if ( Object . keys ( variables . filter ) . length == 0 ) {
82
- delete variables . filter
89
+
90
+ const variables = {
91
+ ...( filter && { filter } ) ,
92
+ sort : { ...sort , sortOrder } ,
93
+ queryString,
94
+ pagination
83
95
}
84
96
const operationName = actionToCamelCase ( actionType )
85
97
@@ -89,7 +101,7 @@ export async function getSavedItemsSearch({
89
101
}
90
102
91
103
function handleResponse ( response ) {
92
- const responseData = response ?. data ?. user ?. searchSavedItems
104
+ const responseData = response ?. data ?. user ?. advancedSearch
93
105
const { pageInfo, edges, totalCount } = responseData
94
106
return { pageInfo, edges, totalCount }
95
107
}
0 commit comments