From fb183b8bfff6e1a13c6fa3f47d632d43bb588d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin?= Date: Wed, 2 Jul 2025 14:21:47 +0200 Subject: [PATCH 1/2] fix(types): FilterFn source should be ResolverFn resolved value --- src/with-filter.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/with-filter.ts b/src/with-filter.ts index c881533..459e759 100644 --- a/src/with-filter.ts +++ b/src/with-filter.ts @@ -1,20 +1,20 @@ export type FilterFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => boolean | Promise; -export type ResolverFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => AsyncIterator | Promise>; +export type ResolverFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => AsyncIterator | Promise>; export type IterableResolverFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => AsyncIterableIterator | Promise>; interface IterallAsyncIterator extends AsyncIterableIterator { [Symbol.asyncIterator](): IterallAsyncIterator; } -export type WithFilter = ( - asyncIteratorFn: ResolverFn, - filterFn: FilterFn +export type WithFilter = ( + asyncIteratorFn: ResolverFn, + filterFn: FilterFn ) => IterableResolverFn; -export function withFilter( - asyncIteratorFn: ResolverFn, - filterFn: FilterFn -): IterableResolverFn { + export function withFilter( + asyncIteratorFn: ResolverFn, + filterFn: FilterFn + ): IterableResolverFn { return async (rootValue: TSource, args: TArgs, context: TContext, info: any): Promise> => { const asyncIterator = await asyncIteratorFn(rootValue, args, context, info); From 1a7ee0729192e24b8e6423d55e97402a162ce34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin?= Date: Wed, 2 Jul 2025 14:29:26 +0200 Subject: [PATCH 2/2] fix: remove optionnal in types --- src/with-filter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/with-filter.ts b/src/with-filter.ts index 459e759..dc5af0c 100644 --- a/src/with-filter.ts +++ b/src/with-filter.ts @@ -1,6 +1,6 @@ -export type FilterFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => boolean | Promise; -export type ResolverFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => AsyncIterator | Promise>; -export type IterableResolverFn = (rootValue?: TSource, args?: TArgs, context?: TContext, info?: any) => AsyncIterableIterator | Promise>; +export type FilterFn = (rootValue: TSource, args: TArgs, context: TContext, info?: any) => boolean | Promise; +export type ResolverFn = (rootValue: TSource, args: TArgs, context: TContext, info?: any) => AsyncIterator | Promise>; +export type IterableResolverFn = (rootValue: TSource, args: TArgs, context: TContext, info?: any) => AsyncIterableIterator | Promise>; interface IterallAsyncIterator extends AsyncIterableIterator { [Symbol.asyncIterator](): IterallAsyncIterator;