Type safety between resolver decorator and resolver return value #1313
Unanswered
miloofcroton
asked this question in
Q&A
Replies: 1 comment
-
See https://github.com/borremosch/eslint-plugin-type-graphql |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm relatively new to decorators and type-graphql, but not typescript or graphql in general.
Correct code:
No type error #1:
No type error #2:
This is a field in a class for all
Post
resolvers. It seems there's no connection between the@Query
decorator's first param (a function with a[Post]
return) and the return value of the functionasync getPosts()
, which isPromise<Post[]>
. If I change the value fromPost[]
toPost
, no type error pops up.I'm not sure if I'm using the library incorrectly or if the library just doesn't support fully type-safe resolvers with one source of truth. Can anyone shed light on this?
Beta Was this translation helpful? Give feedback.
All reactions