benawad / type-graphql-series

Typescript GraphQL Server built with TypeGraphQL
326 stars 129 forks source link

"message": "No repository for \"GuestUserEntity\" was found. Looks like this entity is not registered in current \"default\" connection?", #24

Open sathish-1997 opened 3 years ago

sathish-1997 commented 3 years ago

hello ben awad great series, but in my playground im encountering this problem. Please help me out "message": "No repository for \"GuestUserEntity\" was found. Looks like this entity is not registered in current \"default\" connection?",

henriquesaias commented 3 years ago

I'm having exactly the same problem, anyone knows the solution for this?

kateile commented 3 years ago

@henriquesaias post your typeorm config and entity location I will help you solving it

henriquesaias commented 3 years ago

Awesome, thank you

{
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "postgres",
  "password": "postgres",
  "database": "SeedsOfLight",
  "entities": ["./src/entities/*.ts"],
  "migrations": ["./src/migrations/*.ts"],
  "cli": {
    "migrationsDir": "./src/migrations/"
  }
}

my entity is in src/entities/PlaylistSong.ts in the same folder as all the other entities that are working fine

kateile commented 3 years ago

There is problem in locating entities. Typeorm cant read them. Why don't you use something like "entities": ["src/entities/*.*"], in configuration and make sure typeorm.json/js is on root

henriquesaias commented 3 years ago

I just spotted the bug. Stupid mistake on my part.

In my createSongsLoader I had

import { PlaylistSong } from "../entities/playlistSong"; instead of import { PlaylistSong } from "../entities/PlaylistSong";

Problem solved. Thank you for your time :)