[TypeScript Resolvers] Resolvers returned data type cannot be introspected
See original GitHub issueDescribe the bug Cannot introspect resolvers returned data
To Reproduce Steps to reproduce the behavior:
Clone repository:
git clone -b graphql-ts https://github.com/swcarlosrj/SpaceX-API.git
Install deps & start server:
yarn && yarn start
Generate types:
yarn generate
Introspect src/schema/capsule/resolvers.ts resolvers returned data
Expected behavior
This would be the desired behaviour, it’s not even real because I’ve hardcoded
QueryResolvers.CapsulesResolver
from
CapsulesResolver<...> = (Resolver<R, Parent, Context, CapsulesArgs>
to
CapsulesResolver<...> = Promise<Capsule[]>
I believe that it’s a TypeScript thing but it’d be incredible if we could have that feature using QueryResolvers.Resolvers as here, does it’s even possible?
Environment: OS: macOS Mojave 10.14.2 (18C54) Codegen: 0.15.2 Node: 10.10.0
Additional context It looks like that when you check the returned data type, it’s well formed (in this case Capsule[]) but I cannot see in VSCode the fields of my type/interface as here
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Sure, you can close it!
@swcarlosrj this is how TypeScript works.
When you do this:
TypeScript treats that as a shape of a returned value, not as function’s signature.
To have typed arguments and others, you would have to define that signature, otherwise it’s
any
. That’s why I don’t understand why not to put theTypeResolvers.Resolvers
signature next to the object.