@@ -11,11 +11,11 @@ const resolver = {
1111 }
1212} ;
1313
14- async function list ( filter , sort , currentPage , pageSize , search , context , rootValue , _sourceInclude , _sourceExclude ) {
14+ async function list ( filter , sort , currentPage , pageSize , search , context , rootValue , _source_include , _source_exclude ) {
1515 let _req = {
1616 query : {
17- _source_exclude : _sourceExclude ,
18- _source_include : _sourceInclude
17+ _source_exclude,
18+ _source_include
1919 }
2020 }
2121
@@ -34,26 +34,28 @@ async function list (filter, sort, currentPage, pageSize, search, context, rootV
3434 index : esIndex ,
3535 type : config . elasticsearch . indexTypes [ 0 ] ,
3636 body : query ,
37- _sourceInclude ,
38- _sourceExclude
37+ _source_include ,
38+ _source_exclude
3939 } ) ;
4040
41- if ( esResponse && esResponse . hits && esResponse . hits . hits ) {
41+ const { body } = esResponse
42+
43+ if ( body && body . hits && body . hits . hits ) {
4244 // process response result (caluclate taxes etc...)
43- esResponse . hits . hits = await esResultsProcessor ( esResponse , _req , config . elasticsearch . indexTypes [ 0 ] , esIndex ) ;
45+ body . hits . hits = await esResultsProcessor ( body , _req , config . elasticsearch . indexTypes [ 0 ] , esIndex ) ;
4446 }
4547
4648 let response = { }
4749
4850 // Process hits
4951 response . items = [ ]
50- esResponse . hits . hits . forEach ( hit => {
52+ body . hits . hits . forEach ( hit => {
5153 let item = hit . _source
5254 item . _score = hit . _score
5355 response . items . push ( item )
5456 } ) ;
5557
56- response . total_count = esResponse . hits . total
58+ response . total_count = body . hits . total
5759
5860 // Process sort
5961 let sortOptions = [ ]
@@ -66,7 +68,7 @@ async function list (filter, sort, currentPage, pageSize, search, context, rootV
6668 )
6769 }
6870
69- response . aggregations = esResponse . aggregations
71+ response . aggregations = body . aggregations
7072 response . sort_fields = { }
7173 if ( sortOptions . length > 0 ) {
7274 response . sort_fields . options = sortOptions
0 commit comments