TypeScript Resolvers plugin doesn't allow null to be returned from a promise #6173
Open
Labels
core
Related to codegen core/cli
stage/0-issue-prerequisites
Needs more information before we can start working on it
Describe the bug
Given a query with an optional response:
I should be able to write a resolver that returns a promise that returns null:
However, I can't because the return type is defined like this:
Maybe<ResolverTypeWrapper<SubscriptionDetails>>
So I can return null immediately (thanks to the
Maybe
), but if I return a Promise then I have to returnResolverTypeWrapper<SubscriptionDetails>
, which is defined as:export type ResolverTypeWrapper<T> = Promise<T> | T;
Where the type T itself (SubscriptionDetails in the example) isn't null, so I can't return null.
Proposed Solution:
If the response is optional then the generated code should be something like:
Maybe<ResolverTypeWrapper<Maybe<SubscriptionDetails>>>
The text was updated successfully, but these errors were encountered: