my god, how awesome is that time I wasted on graphl apollo without typescript, no more! thank a lot
@Gualcm5 жыл бұрын
I believe formatArgumentValidationError was removed from type-graphql. I get an error that there is no such export, and I can't find formatArgumentValidationError on type-graphql's documentation.
@bawad5 жыл бұрын
yeah that function did get removed
@4ware5 жыл бұрын
@@bawad And? How would you do it now?
@willcalltickets5 жыл бұрын
@@4ware - this is done automatically now. Just remove that line from the ApolloServer call in index.ts - and remove the import formatArgumentValidationError from type-graphql. in index.ts should be const apolloServer = new ApolloServer({ schema });
@fullstackgreekdeveloper80334 жыл бұрын
In the meantime they have left it as it was in the docs! :)
@lenhu70894 жыл бұрын
@@willcalltickets thank you
@djchrisi4 жыл бұрын
Do not forget the '--no-notify' flag of ts-node-dev. Otherwise it'll drive you crazy.
@pavle6494 жыл бұрын
you've saved my life
@TruthVideosOnline5 жыл бұрын
I LOVE TypeGraphQL!!!
@netstereo5 жыл бұрын
Go Ben, go!
@ChaseOhlson194 жыл бұрын
FYI - Error validation has been deprecated in the newest versions of TypeGraphQL
@aigod_5 жыл бұрын
this series is sick!
@raphaelgarcia49755 жыл бұрын
Ben very good your videos, it helps me a lot in the day to day! How do I make a many to many insertion with typegraphql?
@bawad5 жыл бұрын
Do you know how to do it with regular graphql? It's the same way and in typeorm you can do this: typeorm.io/#/many-to-many-relations
@swashataghosh74625 жыл бұрын
Thank you very much Ben. This is really very helpful.
@EJIROEDWIN4 жыл бұрын
Basically, looks like in new ApolloServer the formatArgumentValidationError is not needed anymore
@peterm.souzajr.21125 жыл бұрын
custom decorator, super cool.
@vigneshs28864 жыл бұрын
@Ben Awad is the class-validator a replacement for joi validator when it comes down to this kind of typescript, typeorm architecture?
@bawad4 жыл бұрын
Yes, but I actually like Joi/yup better
@mikebrecht9703 жыл бұрын
Pro tips: - formatArumentValidation doesn't exist anymore. The functionality that it provided should be included in the current version of type-graphql with no additional work. - You don't need to build a custom decorator to check if the email is already in use. If you set the field to be unique ( @Column("text", { unique: true }) ), then you should get an error message when trying to register a second user with the same email. Mine looks like this: message: "duplicate key value violates unique constraint \"UQ_e12875dfb3b1d92d7d7c5377e22\""
@CardinalHijack4 жыл бұрын
Why do we bother doing the custom decorator at 10:20, when we check the email is unique in the Users.ts file in the entity folder?
@bawad4 жыл бұрын
just for example purposes
@Lee-qj4hk4 жыл бұрын
8:02 "Now, I'm not actually sure what exactly a good first-name, last-name length would be...": en.wikipedia.org/wiki/Hubert_Blaine_Wolfeschlegelsteinhausenbergerdorff_Sr. (1024 ?)
@siafudev71725 жыл бұрын
You mentioned using a new way to organize your files and folders, can you share the link?
It feels a bit like writing Java in Spring lol Jk, good job
@bawad5 жыл бұрын
with all the decorators it does have that feel
@MrEnsiferum774 жыл бұрын
i've tried this days to run ts-node-dev inside docker container, but I had issues with running it in watch mode. But after running "nodemon -L src/index.ts", actually nodemon, now is smart enough to run "ts-node-dev --respawn src/index.ts" under the hood.
@PaulPushkarov5 жыл бұрын
It seems like developer needs to define validation rules twice - first time in User model and second time in RegisterInput. It does not pickup validation rules from model, just throws "server error", is there a way to avoid duplication? Thanks.
@bawad5 жыл бұрын
you could remove the validation from the db and just do application validation
@PaulPushkarov5 жыл бұрын
@@bawad Yeah, but then my objects won't be validated if I create them outside of graphql context.
@PaulPushkarov5 жыл бұрын
@@bawad For now went with a custom save() method saveInResolver (extended BaseEntity) that validates the model and throws new UserInputError('...', {validationErrors}) in cases of validation errors...
@сергейказаков-н8щ5 жыл бұрын
Hi, Ben. Could you publish a gist with your vs code extensions using Settings Sync vs code extension?
@bawad5 жыл бұрын
I'll set that up, in the mean time I have my extensions in the description: kzbin.info/www/bejne/r6a5Y4KufK90e80
@сергейказаков-н8щ5 жыл бұрын
@@bawad Thank you
@christiangyaban96665 жыл бұрын
Ben... thanks for sharing...pls could you show how type-graphql handle file upload
@bawad5 жыл бұрын
I think uploading a file would work the same with or without type-graphql
@christiangyaban96665 жыл бұрын
@@bawad I tried but it didn't work as it was complaining so I have to drop type-graphql for something else but I hope you can try it out
@benjidaniel55955 жыл бұрын
Christian Gyaban you could possible just use a simple rest api for your file upload and continue to use Type-GraphQL for everything else
@CardinalHijack4 жыл бұрын
Man I missed the auto import at 12:15 - my vscode didnt auto import. Spent an hour working out why I was getting no error message in the graphQL playground (everything ran fine). Would be cool to just clarify any imports I think.
@netstereo5 жыл бұрын
Hi Ben. Do you know how we can further customize the error returned by formatArgumentValidationError? Maybe return an array of objects with the "faulty" property name and the error message as the value? Right now even the password is returned
@19majkel945 жыл бұрын
It returns the payload that user sent, so it's not a data leak I think :P But in `formatError` you can do anything you need for safety, the built-in helper is just a few lines, for newcomers mostly.
@@19majkel94 Yeah, newcomers, like me :D Thanks Michal for your work with TypeGraphQL
@jeremyh98413 жыл бұрын
there is a problem with the new flag in tsconfig : "esModuleInterop": true and the import Express from 'express' line...
@Iwillownyouandbehappy5 жыл бұрын
What is the difference between @ArgsType() and @InputType() ?
@bawad5 жыл бұрын
@InputType() creates a graphql input type graphql.org/graphql-js/mutations-and-input-types/ @ArgsType() creates an argument graphql.org/graphql-js/passing-arguments/
@Iwillownyouandbehappy5 жыл бұрын
@@bawad Thanks Ben! Can't wait for next episode :D
@GizmoDuck55 жыл бұрын
Not exactly sure why I'm getting this but haven't seen anyone else with this issue. When I use the formatError: formatArgumentValidationError option I get a typescript error. [ERROR] 09:27:28 ⨯ Unable to compile TypeScript: src/index.ts(16,51): error TS2322: Type '(err: GraphQLError) => { [key: string]: any; }' is not assignable to type '(error: GraphQLError) => GraphQLFormattedError'. Type '{ [key: string]: any; }' is missing the following properties from type 'GraphQLFormattedError': message, locations, path I have followed the tutorial pretty much to a T. Only thing I can come up with is a version difference potentially in one of the dependencies.
@bawad5 жыл бұрын
yeah I think your right, apollo-server probably changed it's typescript definitions with a new version I would just cast it to any: formatError: formatArgumentValidationError as any
@GizmoDuck55 жыл бұрын
@@bawad Submitted an issue into type-graphql as well
@bawad5 жыл бұрын
That's a good idea, type-graphql will want to match up it's type definitions