Connection "default" not found
See original GitHub issueIssue type:
[x] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.14
I’ve tried the other issues related to this but none worked unfortunately.
I’m using Typeorm in combination with Express and Apollo Server
The createConnection step goes well, but when I’m calling a specific resolver (the Register one, a Graphql mutation resolver to sign up to my app), I’m getting Uncaught (in promise) Error: GraphQL error: Connection "default" was not found.
in my browser console
How I create my connection :
await createConnection(connectionOptions);
the value of connectionOptions is what I have in my ormconfig.js :
module.exports = {
name: "production",
type: "postgres",
host: "db", // db is the name of my Docker service running the database
port: 5432,
username: process.env.ORM_USER,
password: process.env.ORM_PASSWORD,
database: process.env.ORM_DB,
synchronize: true,
logging: false,
entities: [process.env.ORM_ENTITIES],
migrations: [process.env.ORM_MIGRATIONS],
subscribers: [process.env.ORM_SUBSCRIBERS],
cli: {
entitiesDir: process.env.ORM_ENTITIES_DIR,
migrationsDir: process.env.ORM_MIGRATIONS_DIR,
subscribersDir: process.env.ORM_SUBSCRIBERS_DIR
}
};
my env variables seem correct (ORM_ENTITIES = “dist/entity/**/*.js”, which is the correct path)
my User entity :
...
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column("text")
email: string;
@Column("text", { nullable: true })
username: string | null;
@Column("text")
password: string;
...
The problem doesn’t seem to be in my resolver, because the console.logs I put in it are not reached
This issue occurs in production, I don’t have it in local development
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
If this is still an issue for anyone, I’ve solved it by making a factory function:
And then I import the function to use:
I got the same issue and solved it by using
instead of