You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using __resolveReference to resolve an interface, it ends up passing a promise to __resolveType. It is my understanding that while __resolveType can return a promise, it should not receive a promise.
In my example, if I take out the __resolveType, I get an expected error about needing to implement __resolveType or isTypeOf. If I make the __resolveReference synchronous, everything works fine. But if it's async (like it would be if it hit an actual database), then the type of the object going into __resolveType is a promise which means that it won't match any of my conditionals.
I was able to make a codesandbox with this issue. I was originally trying to do this with typegraph, but when I ran into the issue, I decided to take that out of the equation and came up with this. I have a PR over there as well: MichalLytek/type-graphql#1448
This seems like a legitimate issue (if it's not then we surely must have another way of accomplishing what you're after). I've opened a PR with a reproduction and a proposed fix, I'll surface it to the team. Thanks for taking the time to put together a reproduction!
Issue Description
When using __resolveReference to resolve an interface, it ends up passing a promise to __resolveType. It is my understanding that while __resolveType can return a promise, it should not receive a promise.
In my example, if I take out the __resolveType, I get an expected error about needing to implement __resolveType or isTypeOf. If I make the __resolveReference synchronous, everything works fine. But if it's async (like it would be if it hit an actual database), then the type of the object going into __resolveType is a promise which means that it won't match any of my conditionals.
I was able to make a codesandbox with this issue. I was originally trying to do this with typegraph, but when I ran into the issue, I decided to take that out of the equation and came up with this. I have a PR over there as well: MichalLytek/type-graphql#1448
Link to Reproduction
https://codesandbox.io/p/sandbox/naughty-keldysh-phhss6?file=%2Fsrc%2Fproducts.ts
Reproduction Steps
I've set it up so "Product" is an interface for
Book
s andMovie
s.Run this of :4000 (the supergraph):
You can also run the reference resolution query directly on the products subgraph (:4001):
The text was updated successfully, but these errors were encountered: