nestjs, typeorm, graphql- 1
common error
Nest can't resolve dependencies of the <provider> (?). Please make sure that the argument <unknown_token> at index [<index>] is available in the <module> context.
Potential solutions:
- If <unknown_token> is a provider, is it part of the current <module>?
- If <unknown_token> is exported from a separate @Module, is that module imported within <module>?
@Module({
imports: [ /* the Module containing <unknown_token> */ ]
})
common error2
TYPEORM
If you run into the following error when trying to connect to MySQL from TypeORM:
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
The reason this happens is explained in detail here, but in short, MySQL 8.0.4 introduced a new default authentication mechanism 'cachingsha2pasword'. This is more secure than the previous method used by MySQL, which is 'mysqlnativepassword'. Now, TypeORM, under the hood, uses mysqljs (I think). Work is being done in order to support this new authentication, however, as of writing, it has not been merged into master. As such, in order to get around this, on MySQL, you need to do the following:
ALTER USER 'userName'@'hostName' IDENTIFIED WITH mysql_native_password BY 'passwordHere';
SELECT plugin FROM mysql.user WHERE User = 'root';
Thereafter, you need to run (from the MySQL terminal):
- FLUSH PRIVILEGES;
- quit
- restart mysql