@Min is only for numbers, use @MinLength instead github.com/benawad/type-graphql-series/blob/9d6c1deb0ed484e544e4d64cb0467530aa50fb7e/src/modules/shared/PasswordInput.ts#L7
Thanks for the video, Ben! Really enjoying the series! I was testing the project until this video and seems like that Min validator is specific for numbers so I had to replace Min by Length. Thanks again!
for PasswordInput validation is good to use @MinLength() method instead of Min() @InputType() export class PasswordInput { @Field() @MinLength(8) password: string; }
In the 9th video in the series I had trouble because I added the Min validator to password as seen at 16:15 into this video. I think it should actually be MinLength. The test in video 9 fails if you do Min.
I'm late to the party but I'm well decided to make a real backend with postgres/graphql/typescript. A question regarding constants: couldn't they be typescript enums?
you can get around that with mixins: const MyMixin = (BaseClass: T) => { @InputType() class SomeInput extends BaseClass { @Field() idk: string; } return SomeInput; }; @InputType() export class RegisterInput extends MyMixin(PasswordInput) { }
When you set up the glob statment with __dirname, wouldn't that also hit files that are not resolvers, for example, redisPrefixes would also fit that glob, no? Does it know that it's not a reslover somehow?
Hi Ben .... fantastic as always! I ran into an issue using the resolvers import using the modules folder.... looks like the "ChangePasswordInput" input type gets imported more than once in the schema. Anyone else face this issue?
@@bawad Yes, the following error: UnhandledPromiseRejectionWarning: Error: Schema must contain unique named types but contains multiple types named "ChangePasswordInput". I am graphql -> 14.1.1, apollo-server-express 2.4.8. I have also noticed in the latest version, the formatArgumentValidationError has been removed... No big issue with the above, i simply sticked to the initial method.... Wanted to say again, thank you very much for your videos! I really enjoy your approach and detailed topics!
@@Narlynarz Hi, yes, everything worked up to this point... Queries, Mutations, etc.... it only caused an issue when loading the resolvers from the folders. Not to worry though, i see later in the testing section Ben moves back to defining the specific resolvers....
Great video, Ben! I see that now we have two places (register and changePassword) where we encrypt the password from user input using bcrypt. The other day I was reading the typeorm documentation and found entity listeners(typeorm.io/#/listeners-and-subscribers). They are like Sequelize hooks and I thought these may help you refactor the encryption code. Let me know what you think of them.
I dont understand the need for a prefix. Could someone link an article or give a simple explanation why this matters? The tokens are not identical so reuse won't happen, unless I am misunderstanding something(probable)
@Min is only for numbers, use @MinLength instead github.com/benawad/type-graphql-series/blob/9d6c1deb0ed484e544e4d64cb0467530aa50fb7e/src/modules/shared/PasswordInput.ts#L7
Thanks for the video, Ben! Really enjoying the series!
I was testing the project until this video and seems like that Min validator is specific for numbers so I had to replace Min by Length.
Thanks again!
thanks
Every video of yours starts with "we're be going over" ;)
sounds accurate 😄
change Min(5) to MinLength(5)
prefix also needed on line 18 at time 13:01 . i look forward to all the rest of your videos!
for PasswordInput validation is good to use @MinLength() method instead of Min()
@InputType()
export class PasswordInput {
@Field()
@MinLength(8)
password: string;
}
I believe @Min() is used for comparing numbers, not string length
use @MinLength(8)
In the 9th video in the series I had trouble because I added the Min validator to password as seen at 16:15 into this video. I think it should actually be MinLength. The test in video 9 fails if you do Min.
very good as usual
I'm late to the party but I'm well decided to make a real backend with postgres/graphql/typescript.
A question regarding constants: couldn't they be typescript enums?
What if you wanted to extract multiple fields into their own input classes? You can't extend multiple classes (in TS).
you can get around that with mixins:
const MyMixin = (BaseClass: T) => {
@InputType()
class SomeInput extends BaseClass {
@Field()
idk: string;
}
return SomeInput;
};
@InputType()
export class RegisterInput extends MyMixin(PasswordInput) {
}
When you set up the glob statment with __dirname, wouldn't that also hit files that are not resolvers, for example, redisPrefixes would also fit that glob, no? Does it know that it's not a reslover somehow?
yeah it would, I think type-graphql just takes the classes with @Resolver decorator on it
great video
Hi Ben .... fantastic as always!
I ran into an issue using the resolvers import using the modules folder.... looks like the "ChangePasswordInput" input type gets imported more than once in the schema.
Anyone else face this issue?
does it cause some kind of error?
@@bawad Yes, the following error: UnhandledPromiseRejectionWarning: Error: Schema must contain unique named types but contains multiple types named "ChangePasswordInput". I am graphql -> 14.1.1, apollo-server-express 2.4.8.
I have also noticed in the latest version, the formatArgumentValidationError has been removed...
No big issue with the above, i simply sticked to the initial method....
Wanted to say again, thank you very much for your videos! I really enjoy your approach and detailed topics!
@@Narlynarz Hi, yes, everything worked up to this point... Queries, Mutations, etc.... it only caused an issue when loading the resolvers from the folders.
Not to worry though, i see later in the testing section Ben moves back to defining the specific resolvers....
Can we extends typeorm entities too?
If all or at least some my entities have shared fields.
Hi Ben, is there a better way to handle errors and display those to users?
sometimes I just return the error through graphql
Great video, Ben!
I see that now we have two places (register and changePassword) where we encrypt the password from user input using bcrypt. The other day I was reading the typeorm documentation and found entity listeners(typeorm.io/#/listeners-and-subscribers). They are like Sequelize hooks and I thought these may help you refactor the encryption code. Let me know what you think of them.
Yeah I think that would make for a nice refactoring
I dont understand the need for a prefix. Could someone link an article or give a simple explanation why this matters? The tokens are not identical so reuse won't happen, unless I am misunderstanding something(probable)
If I want to lookup all keys for a specific thing I can look for the prefix
@@bawad thanks!