Replace `Promise` with `PromiseLike` in resolver types
#6.378 geöffnet am 29. Juli 2021
Repository-Metriken
- Stars
- (10.341 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 22T 9h) (53 gemergte PRs in 30 T)
Beschreibung
Is your feature request related to a problem? Please describe.
When using non-native Promise library like Bluebird, the return type of resolvers will often be PromiseLike, but it doesn't adapt with generated resolver-types because the generated code is using native Promise type.
sample code:
const resolvers: Resolvers = {
Query: {
name: () => { // string field
return Promise.resolve('1') as PromiseLike<string>
}
}
}
error message:
(...omitted)
Type 'PromiseLike<string>' is not assignable to type 'ResolverTypeWrapper<string> | Promise<ResolverTypeWrapper<string>>'.
Type 'PromiseLike<string>' is missing the following properties from type 'Promise<ResolverTypeWrapper<string>>': catch, finally, [Symbol.toStringTag]
Describe the solution you'd like
Can Promise be just replaced with PromiseLike?
Describe alternatives you've considered
We can customize it by using customResolverFn.
So this feature request is not mandatory, but I feel it's better if I don't have to customize and manage it in our code.
Additional context