Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GraphQL resolvers that returns observables #41

Closed
kctang opened this issue Aug 3, 2018 · 2 comments
Closed

Support GraphQL resolvers that returns observables #41

kctang opened this issue Aug 3, 2018 · 2 comments

Comments

@kctang
Copy link

kctang commented Aug 3, 2018

Hi, I am new to NestJS, so I hope this issue is not my mistake. I think NestJS's GraphQL module does not support resolvers that returns observables. This is kind of unexpected as the REST counterpart (i.e. controllers) supports observables.

With heyPromise, I am able to get 'from promise'. However, heyObservable returns this instead:

{
  "data": {
    "heyObservable": "[object Object]"
  }
}

The expected data for heyObservable should be 'from rxjs'. For now, we will need to workaround by turning the observable into a promise (i.e. heyObservable_workaround_is_ok)

Snippet of schema & resolvers used:

type Query {
    heyPromise: String
    heyObservable: String
}

  @Query()
  async heyPromise () {
    return new Promise(resolve => resolve('from promise'))
  }

  @Query()
  heyObservable () {
    return of('from rxjs')
  }

  @Query()
  heyObservable_workaround_is_ok () {
    return of('from rxjs').toPromise()
  }
@kamilmysliwiec
Copy link
Member

This feature is available in the latest version of the package.

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants