Skip to content

Commit 77f0492

Browse files
fix: provide compatibility with @elastic/elasticsearch.js
* Update search.ts Provides compatibility with @elastic/elasticsearch.js * style: fix eslint/prettier warnings Co-authored-by: nodkz <[email protected]>
1 parent 399ca3e commit 77f0492

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/resolvers/search.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,19 @@ export default function createSearchResolver<TSource, TContext>(
175175
}
176176

177177
const res: any = await searchFC.resolve(rp.source, args, rp.context, rp.info);
178-
179-
res.count =
180-
typeof res.hits.total?.value === 'number' ? res.hits.total.value : res.hits.total;
181-
res.max_score = res.hits.max_score;
182-
res.hits = res.hits.hits;
183-
178+
if (typeof res.hits === 'undefined') {
179+
res.count =
180+
typeof res.body.hits.total?.value === 'number'
181+
? res.body.hits.total.value
182+
: res.body.hits.total;
183+
res.max_score = res.body.hits.max_score;
184+
res.hits = res.body.hits.hits;
185+
} else {
186+
res.count =
187+
typeof res.hits.total?.value === 'number' ? res.hits.total.value : res.hits.total;
188+
res.max_score = res.hits.max_score;
189+
res.hits = res.hits.hits;
190+
}
184191
return res;
185192
},
186193
})

0 commit comments

Comments
 (0)