Skip to content

Commit

Permalink
loosen resolvers subscribe return type (#7015)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l authored Nov 14, 2021
1 parent 321a27c commit 3d57ec6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-lizards-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/typescript-resolvers': patch
---

loosen return type of SubscriptionSubscribeFn from `PromiseOrValue<AsyncIterator>` to `PromiseOrValue<AsyncIterable>`. This fixes type conflicts with libraries such as `ix/asynciterable` and is what `graphql-js` expects.
2 changes: 1 addition & 1 deletion dev-test/modules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/resolvers-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/resolvers-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/resolvers-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/typescript/resolvers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info${optionalSignForInfoArg}: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down Expand Up @@ -285,7 +285,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down Expand Up @@ -535,7 +535,7 @@ export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
args: TArgs,
context: TContext,
info?: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
Expand Down

0 comments on commit 3d57ec6

Please sign in to comment.