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(
7878 ...additionalArgs ,
7979 sort : {
8080 type : sortEnumType ,
81- defaultValue : sortEnumType . getValues ( ) [ 0 ] . value , // first enum used by default
81+ defaultValue : sortEnumType . getValues ( ) [ 0 ] . name , // first enum used by default
8282 description : 'Sort argument for data ordering' ,
8383 } ,
8484 } ,
@@ -90,12 +90,29 @@ export function prepareConnectionResolver(
9090 resolveParams ,
9191 { args : { } } // clear this params in copy
9292 ) ;
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+ }
94109
95110 findManyParams . args . filter = prepareFilter ( args ) ;
96111 findManyParams . args . sort = sortOptions . sortValue ;
97112
98- findManyParams . projection = projection && projection . edges && projection . edges . node ;
113+ if ( projection && projection . edges ) {
114+ findManyParams . projection = projection . edges . node || { } ;
115+ }
99116 sortOptions . uniqueFields . forEach ( fieldName => {
100117 findManyParams . projection [ fieldName ] = true ;
101118 } ) ;
You can’t perform that action at this time.
0 commit comments