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
I'm using an external library to generate part of my schema. The library support async resolvers but isn't aware they are allowed to be AsyncIterators/Observables, and as such I end up with strings saying [object Object] if I try to use Observables in the partially generated resolvers. As far as I can tell, this is because the library wraps the result in a Promise, resulting in an Observable wrapped in a Promise which is just interpreted as being a Promise resolving to an object.
I will probably end up solving this by fixing this myself on the library, but I was thinking this might be a broader problem that might be generally solvable by considering Promises for Observables to be a valid use case. Curious about your thoughts. 😃
The text was updated successfully, but these errors were encountered:
The library works by allowing you to provide a set of resolvers for different use-cases, each of which may return a Promise or not. The library then wraps the result of the resolvers in a Promise and does some processing before handing it off to GraphQL. Basically, I'd have to update the library anyway to fix the processing, but I think most of the processing doesn't affect the results, so the Observable I return from the resolvers it ending up in the proper place, it is just wrapped in a Promise.
I would guess many schema-generating tools work in a similar manner:
Provide some resolver functions, async or not.
Library does some connecting up, maybe some checking of results but usually no modification, except wrapping in Promise to ensure async things work correctly.
Wrapping with prepareSchema breaks on Observables because they are also being wrapped in a Promise.
I'm using an external library to generate part of my schema. The library support async resolvers but isn't aware they are allowed to be AsyncIterators/Observables, and as such I end up with strings saying
[object Object]
if I try to use Observables in the partially generated resolvers. As far as I can tell, this is because the library wraps the result in a Promise, resulting in an Observable wrapped in a Promise which is just interpreted as being a Promise resolving to an object.I will probably end up solving this by fixing this myself on the library, but I was thinking this might be a broader problem that might be generally solvable by considering Promises for Observables to be a valid use case. Curious about your thoughts. 😃
The text was updated successfully, but these errors were encountered: