File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export function prepareConnectionResolver(
78
78
...additionalArgs ,
79
79
sort : {
80
80
type : sortEnumType ,
81
- defaultValue : sortEnumType . getValues ( ) [ 0 ] . value , // first enum used by default
81
+ defaultValue : sortEnumType . getValues ( ) [ 0 ] . name , // first enum used by default
82
82
description : 'Sort argument for data ordering' ,
83
83
} ,
84
84
} ,
@@ -90,12 +90,29 @@ export function prepareConnectionResolver(
90
90
resolveParams ,
91
91
{ args : { } } // clear this params in copy
92
92
) ;
93
- const sortOptions : connectionSortOpts = args . sort ;
93
+ let sortOptions : connectionSortOpts ;
94
+ if ( typeof args . sort === 'string' ) {
95
+ const sortValue = sortEnumType . parseValue ( args . sort ) ;
96
+ if ( sortValue ) {
97
+ sortOptions = sortValue ;
98
+ } else {
99
+ sortOptions = {
100
+ sortValue : { } ,
101
+ uniqueFields : [ ] ,
102
+ // $FlowFixMe
103
+ directionFilter : filter => filter ,
104
+ } ;
105
+ }
106
+ } else {
107
+ sortOptions = args . sort ;
108
+ }
94
109
95
110
findManyParams . args . filter = prepareFilter ( args ) ;
96
111
findManyParams . args . sort = sortOptions . sortValue ;
97
112
98
- findManyParams . projection = projection && projection . edges && projection . edges . node ;
113
+ if ( projection && projection . edges ) {
114
+ findManyParams . projection = projection . edges . node || { } ;
115
+ }
99
116
sortOptions . uniqueFields . forEach ( fieldName => {
100
117
findManyParams . projection [ fieldName ] = true ;
101
118
} ) ;
You can’t perform that action at this time.
0 commit comments