@@ -5,7 +5,6 @@ import { TypeComposer, InputTypeComposer } from 'graphql-compose';
55import composeWithConnection from 'graphql-compose-connection' ;
66import { convertModelToGraphQL } from './fieldsConverter' ;
77import * as resolvers from './resolvers' ;
8- import { OPERATORS_FIELDNAME } from './resolvers/helpers/filter' ;
98
109import type {
1110 MongooseModelT ,
@@ -139,37 +138,35 @@ export function prepareConnectionResolver(
139138 countResolverName : 'count' ,
140139 sort : {
141140 _ID_DESC : {
142- uniqueFields : [ ' _id' ] ,
143- sortValue : { _id : - 1 } ,
144- directionFilter : ( filter , cursorData , isBefore ) => {
141+ value : { _id : - 1 } ,
142+ cursorFields : [ ' _id' ] ,
143+ beforeCursorQuery : ( rawQuery , cursorData ) => {
145144 // $FlowFixMe
146- filter [ OPERATORS_FIELDNAME ] = filter [ OPERATORS_FIELDNAME ] || { } ;
145+ if ( ! rawQuery . _id ) rawQuery . _id = { } ;
147146 // $FlowFixMe
148- filter [ OPERATORS_FIELDNAME ] . _id = filter [ OPERATORS_FIELDNAME ] . _id || { } ;
149- if ( isBefore ) {
150- filter [ OPERATORS_FIELDNAME ] . _id . gt = cursorData . _id ;
151- } else {
152- filter [ OPERATORS_FIELDNAME ] . _id . lt = cursorData . _id ;
153- }
147+ rawQuery . _id . $gt = cursorData . _id ;
148+ } ,
149+ afterCursorQuery : ( rawQuery , cursorData ) => {
150+ // $FlowFixMe
151+ if ( ! rawQuery . _id ) rawQuery . _id = { } ;
154152 // $FlowFixMe
155- return filter ;
153+ rawQuery . _id . $lt = cursorData . _id ;
156154 } ,
157155 } ,
158156 _ID_ASC : {
159- uniqueFields : [ ' _id' ] ,
160- sortValue : { _id : 1 } ,
161- directionFilter : ( filter , cursorData , isBefore ) => {
157+ value : { _id : 1 } ,
158+ cursorFields : [ ' _id' ] ,
159+ beforeCursorQuery : ( rawQuery , cursorData ) => {
162160 // $FlowFixMe
163- filter [ OPERATORS_FIELDNAME ] = filter [ OPERATORS_FIELDNAME ] || { } ;
161+ if ( ! rawQuery . _id ) rawQuery . _id = { } ;
162+ // $FlowFixMe
163+ rawQuery . _id . $gt = cursorData . _id ;
164+ } ,
165+ afterCursorQuery : ( rawQuery , cursorData ) => {
164166 // $FlowFixMe
165- filter [ OPERATORS_FIELDNAME ] . _id = filter [ OPERATORS_FIELDNAME ] . _id || { } ;
166- if ( isBefore ) {
167- filter [ OPERATORS_FIELDNAME ] . _id . lt = cursorData . _id ;
168- } else {
169- filter [ OPERATORS_FIELDNAME ] . _id . gt = cursorData . _id ;
170- }
167+ if ( ! rawQuery . _id ) rawQuery . _id = { } ;
171168 // $FlowFixMe
172- return filter ;
169+ rawQuery . _id . $lt = cursorData . _id ;
173170 } ,
174171 } ,
175172 ...opts ,
0 commit comments