Skip to content

sort param should be optional on connection resolver factory opts #337

@yoadsn

Description

@yoadsn

I might read it wrong, but when using the connection resolver factory and specifying opts for findMany (for example) the sort prop is also required. But in fact the factory knows to generate it from the indexes of the model.
Can we make this optional in this type def?

export type ConnectionResolverOpts<TContext = any> = Omit<

I can create a PR if this is indeed something to fix.
Maybe something like this?

--- a/src/resolvers/connection.ts
+++ b/src/resolvers/connection.ts
@@ -2,6 +2,7 @@ import type { Document, Model } from 'mongoose';
 import {
   prepareConnectionResolver,
   ConnectionResolverOpts as _ConnectionResolverOpts,
+  ConnectionSortMapOpts as _ConnectionSortMapOpts,
   ConnectionTArgs,
 } from 'graphql-compose-connection';
 import type { Resolver, ObjectTypeComposer } from 'graphql-compose';
@@ -11,10 +12,11 @@ import { getUniqueIndexes, extendByReversedIndexes, IndexT } from '../utils/getI

 export type ConnectionResolverOpts<TContext = any> = Omit<
   _ConnectionResolverOpts<TContext>,
-  'countResolver' | 'findManyResolver'
+  'countResolver' | 'findManyResolver' | 'sort'
 > & {
   countOpts?: CountResolverOpts;
   findManyOpts?: FindManyResolverOpts;
+  sort?: _ConnectionSortMapOpts;
 };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions