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

Basic NestJS typegoose/typegraphql example not working #60

Open
elie222 opened this issue Jan 29, 2020 · 7 comments
Open

Basic NestJS typegoose/typegraphql example not working #60

elie222 opened this issue Jan 29, 2020 · 7 comments

Comments

@elie222
Copy link

elie222 commented Jan 29, 2020

I put up a basic project using NestJS, Typegoose and TypeGraphQL but the mongo query never returns:
https://github.com/elie222/nestjs-typegraphql-typegoose-example

Specifically in this file:

https://github.com/elie222/nestjs-typegraphql-typegoose-example/blob/master/src/cats/cats.resolver.ts

  @Query(() => [Cat])
  async cats(): Promise<Cat[]> {
    console.log("gets here");

    const cats = await this.catsService.listCats();
    
    console.log("never gets here", cats);

    return cats;
  }

Not sure if this is an issue with this package or Typegoose, or likely I'm just not setting things up as expected. Would be nice to get some sort of feedback but the promise just never returns.

@hasezoey
Copy link
Contributor

to get the right return types you would need to use https://typegoose.github.io/typegoose/docs/types/documentType/

maybe try @types/mongoose 5.6.x (5.7 is not yet tested with typegoose)

otherwise i dont see a problem

@elie222
Copy link
Author

elie222 commented Jan 29, 2020 via email

@hasezoey
Copy link
Contributor

@elie222 how to run your example repo? (i never used nest/graphql) i only got as far as to starting the server and locating localhost:3000/graphql (and /cats dosnt exists, where i would expect it)

@elie222
Copy link
Author

elie222 commented Jan 29, 2020 via email

@hasezoey
Copy link
Contributor

@elie222 i just tested it, and here is what i found:
a simple log of mongoose.connection.readyState reveals that the default connection is not connect to the database, and so the query stalls and waits for the connection to be connected
and from what i have seen, the model you use, Cat is associated with the default connection, but there is an non-default connection that is connected

@kpfromer could you help here? because the example in your repo seems to be almost the same as the one provided here

@hasezoey
Copy link
Contributor

and when trying to use connectionName, it will result in #57

@oliviermattei
Copy link

oliviermattei commented Feb 4, 2020

I have a similar problem.
https://github.com/oliviermattei/nestjs-graphql-typegoose-example

In my case, User module works perfectly but demand module is stuck when I use it. I have
"error": "Failed to fetch. Please check your connection"

In fact the demand way should be better because of the fusion of model and type

Have you an Idea ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants