I really appreciate that you don't skip over safe password storage. Some tutorials mention it, but most don't implement it. In this day and age, with data breaches on the regular, security isn't something to be glossed over, even if it's just a tutorial. New developers are going to continue to code the way they know how, so if they aren't taught best practices from the get-go, it's a much harder road for everyone. So thank you! I find myself praising you every time I watch your videos 😆 You really do a great job! ❤️
I can list events with only this code try { return await Event.find(); } catch (e) { throw e; } i mean i don't need to map events one more time because its the same result. I am returning the array it self but you are returning items one by one. So my version is shorter and easier to understand. It might be about the versions that you were using while recording this series. Can you light me up about this ?
This is a tutorial. I myself use async/await everywhere. But this is a graphQL tut. These are small matters. I am writing code for this tutorial with TypeScript myself with all the types and all. So, its upto you.
🔴 IMPORTANT NOTICE! If you find yourself unable to connect to MongoDB it's because you need to do the IP whitelist step again. The error message isn't helpful. Hope it helps!
Really like the content and topics covered, this is the second such graphql tutorial... but the last video was suuuuuper confusing. It works, and in theory it makes sense, but to re-create that last chunk of code will be a struggle.
Yeah definitely, I refactored it to use async /await and try/catch blocks, so much cleaner and easier to understand. The way he did it is a nightmare lol
To check if email address is unique, instead of search if _id exists you could add to the schema a property called unique and set it to true and mongodb would have checked that for you. Another problem is when you create a new event you save it before check if user exists and you actually save a wrong event, you should have to check if user exist before saving event and avoid the "createdEvent" trick.
instead of checking the database to see if a user with the email already exists. you can just add to your user schema email: { type: String, unique: 'This E-mail is already registered' }
there is actually a bunch of stuff you can do with mongoose schemas to save you time. For example this is from my code, I also have a validEmail function to validate the email right in the schema: email: { type: String, unique: 'This E-mail is already registered', index: true, uniqueCaseInsensitive: true, validate: { validator: v => validEmail(v), message: '{VALUE} is not a valid email', }, required: [true, 'Email required'], },
Hi, I just have a question. Isn't it better to use .updateOne instead of using find -> save? Using find -> save can cause a race condition right? But great series anyways!!
Great tutorial as usual , but a question : don't we have to put the "creator" field in the Event type of the graphql schema ? i mean what if the front end requested for the creator of a certain event ?
If you weren't using async/await from the start, don't complain about him not using it in this tutorial. If you are complaining it is more than likely because you dont know the fundamentals of async functions, so go back and watch a tutorial on async/await and come back when you can actually think for yourself.
Hi. In Andrew Mead tutorial, he made relationship between a User with Tasks where he used userSchema.virtual... to relate different Tasks a User has. It's a bit complicated because aside from having ref field, he also added the localField and foreignField in that userSchema.virtual. What is the difference between him and yours where you literally just put an array of events inside a User model? Thank you. By the way, i have finished net ninja graphql tuts and yours is a bit deeper than his that's is why im loving it. Regards.
Hello, Thank you for the video. I am following your tutorial however I hit a wall with this error "Error: Cannot find module 'graphql'" when trying to run the server. Thank you ... Please help
Great tutorial, super useful stuff! It's nice that you remote the password from the return data at 14:43, however, later on when you add the relations and possibility to viewing events and bookings, it's possible to step in to the Creator property and access the password (although hashed) that way. Would you have a suggestion on how to prevent returning the password at all times?
Thanks for the great tutorials, Max. I’m just curious why everyone still uses -save when they npm install things. Hasn’t it saved to package.json by default for a while now?
True - I'm just used to adding this. And for tutorials, I like to add it for clarity, too. It really makes it easier (hopefully) to differentiate dev and prod dependencies.
Hi Max! Thank you for your videos! Wouldn't be cleaner for your resolvers if you push a created event's id in createdEvents array on eventSchema.post("save",...)?
Hi Max, thank you for all your effort. This is such a useful as usual. May I ask you to add this episode and the previous one into the playlist? Best Regards, Balazs
Maybe a little late, but try to remove the return { ...result._doc }; underneath the return User.findById line and make sure that the user id in the code matches the user id in the mongodb.
I am not able to connect to MongoDB database and getting below error. name: 'MongoNetworkError', errorLabels: [ 'TransientTransactionError' ], [Symbol(mongoErrorContextSymbol)]: {} } [nodemon] clean exit - waiting for changes before restart
Sometimes, get the current IP address function in the Mongo console does not return your correct IP. You can get the IP address by yourself and add there. At least, that's what i did, and it worked.
I'm use sequelize on sql and for the email verification have a property of relational db name unique and verified that, nice video series liked a lot (y)
@@sebastianjung3168 "unique: true" works for unique value validation as expected, and we avoid the extra "User.findOne()" search. You can also use mongoose-unique-validator plugin to return a friendlier error message.
Does it bother anyone else that your schema is just a template string? That’s the only thing I don’t like about GraphQL so far. I keep feeling like I’m doing it wrong
Thank you for the video I just want to add that instead of checking if the user already existed we can do the following in the model email: { type: String, unique: true, // this will make sure that there will be no duplicate email required: [true, 'An email is required for a user'], }, password: { type: String, required: [true, 'A password is required for a user'], select: false, // this wont return the password when we query for it },
First thank you very much, I really appreciate this. Second, please post the full course at once. I'm not sure about what is your market strategy here, but on our side though, at times our job will let us allocate a chunk of time on the side to learn a new tech. Your tutorial is great but it's counterproductive and less likely that I can convince my boss to make random stops and wait to whenever you post your next video. I'm sure I'm not the only one on this boat here...
Thank you for your great feedback and for your suggestion Tonki! Releasing the videos step-by-step is an additional service for all of you (besides the fact that this series is 100% for free) as I'm still recording the videos and I want to make sure you can access the videos as fast as possible. You always have the option to wait until the entire series is released, but then you have to wait a bit - that's kind of the deal.
Dude, I think you should have just stopped at "Thank you" I can't imagine why you feel you are entitled to demand the videos to be put out in the way you want.
Aren't there foreign keys in mongodb? Why can we not simply have the creator field on the events collection and be done with it? You no longer have a single source of truth with the current approach.
I really appreciate that you don't skip over safe password storage. Some tutorials mention it, but most don't implement it.
In this day and age, with data breaches on the regular, security isn't something to be glossed over, even if it's just a tutorial.
New developers are going to continue to code the way they know how, so if they aren't taught best practices from the get-go, it's a much harder road for everyone.
So thank you! I find myself praising you every time I watch your videos 😆
You really do a great job! ❤️
Thanks a million for this fantastic feedback, reading this honestly means a lot to me!
I like this series because there is no previously written code. Everything is written from scratch and each line of code is explained.
You are one of the best teachers in my life. Thank you for your videos. These videos helping me to become a better developer. Love from India.
i don't got why someone hit dislike to this video because this is a very clear video for anybody :)
Always hard to make everybody happy I guess, but it's just great to get the support from you and so many others :)
I was so lost with GraphQL, thank you for this tutorial.
Since there are so many promisese and there are so many .thens shouldn't we just use async await?
We will soon
I can list events with only this code
try {
return await Event.find();
}
catch (e) {
throw e;
}
i mean i don't need to map events one more time because its the same result. I am returning the array it self but you are returning items one by one. So my version is shorter and easier to understand. It might be about the versions that you were using while recording this series.
Can you light me up about this ?
@@N96123 wow this is much more cleaner and readable
thought the same...
This is a tutorial. I myself use async/await everywhere. But this is a graphQL tut. These are small matters. I am writing code for this tutorial with TypeScript myself with all the types and all. So, its upto you.
Thanks for the series , I really appreciate you putting all the effort in putting this together .
Thank YOU for your comment Shawn, happy to read that you like it!
🔴 IMPORTANT NOTICE!
If you find yourself unable to connect to MongoDB it's because you need to do the IP whitelist step again.
The error message isn't helpful. Hope it helps!
thank you so much!!! i was struggling to find the solution
My Brain is fried after all those thens
Really like the content and topics covered, this is the second such graphql tutorial... but the last video was suuuuuper confusing. It works, and in theory it makes sense, but to re-create that last chunk of code will be a struggle.
This is one of the best channel on youtube !
Thanks a lot Khalid, this really means a lot to us!
My Head is spinning to why we are going into promise chain hell as opposed to *async await* . Thoughts?
I agree. It's too difficult to follow along near the end especially for beginners like me
Yeah definitely, I refactored it to use async /await and try/catch blocks, so much cleaner and easier to understand. The way he did it is a nightmare lol
@@JoeWong81
createUser: async (args) => {
const { email, password } = args.userInput;
try {
const emailTaken = await User.findOne({ email: email });
if (emailTaken) {
throw new Error("Email Taken already");
}
const hasedPassword = await bcrypt.hash(password, 12);
const userData = new User({
email: email,
password: hasedPassword,
});
const user = await userData.save();
return user;
} catch (err) {
throw new Error("Error " + err);
}
},
Learned so much from just one video... Danke für dieses wundervolle Vid!
Vielen Dank Aykut :)
To check if email address is unique, instead of search if _id exists you could add to the schema a property called unique and set it to true
and mongodb would have checked that for you.
Another problem is when you create a new event you save it before check if user exists and you actually save a wrong event,
you should have to check if user exist before saving event and avoid the "createdEvent" trick.
instead of checking the database to see if a user with the email already exists. you can just add to your user schema
email: {
type: String,
unique: 'This E-mail is already registered'
}
there is actually a bunch of stuff you can do with mongoose schemas to save you time. For example this is from my code, I also have a validEmail function to validate the email right in the schema:
email: {
type: String,
unique: 'This E-mail is already registered',
index: true,
uniqueCaseInsensitive: true,
validate: {
validator: v => validEmail(v),
message: '{VALUE} is not a valid email',
},
required: [true, 'Email required'],
},
@@rtorcato you wouldnt be by some chance willing to make a video about it right?
Great tutorial series! Thank you for putting these together!
More easily and readable with async await, but good tutorial :D
What does dictate the name of the document we see in the MongoDB GUI (i.e "users" and "events") in the left side of the collections panel ?
Amazing tutorial, I had a confusion with relations in mongoose but you cleared it out thanks a lot :)
Trying to scroll up and down in app.js is frustrating. I wish it was started in seperate files.
Hi,
I just have a question.
Isn't it better to use .updateOne instead of using find -> save?
Using find -> save can cause a race condition right?
But great series anyways!!
Great tutorial as usual , but a question : don't we have to put the "creator" field in the Event type of the graphql schema ? i mean what if the front end requested for the creator of a certain event ?
Great series Max! Thank you for all the energy and effort you put into creating these! (And your Udemy courses are tops too!)
Thanks a lot Michael, great to read that you like my TH-cam videos and Udemy courses :)
why not using await syntax ?
THANK U SO SO SO MUCH MAX!!!!!!! sorry for the spam but this tutorial is exactly what i've been looking for!!!
If you weren't using async/await from the start, don't complain about him not using it in this tutorial. If you are complaining it is more than likely because you dont know the fundamentals of async functions, so go back and watch a tutorial on async/await and come back when you can actually think for yourself.
Adding createdEvents field in user seems to me unnecessary. Do let me know if you feel that is required?
Thank you Max this series really helpful!!!
Thank you Max, great content as always.
Happy to read that you like the video Jamille, thank you!
Nice tutorials, but in this example, it would be much better to use async/await, so you don't have to deal with all those then blocks
Thanks for the tutorial. I am coding-along while using sequelize and postgresql.
We are retuning "creator" in createEvent but didn't specify it in "type event", So is that correct?
Hi. In Andrew Mead tutorial, he made relationship between a User with Tasks where he used userSchema.virtual... to relate different Tasks a User has. It's a bit complicated because aside from having ref field, he also added the localField and foreignField in that userSchema.virtual. What is the difference between him and yours where you literally just put an array of events inside a User model? Thank you. By the way, i have finished net ninja graphql tuts and yours is a bit deeper than his that's is why im loving it. Regards.
Hello, Thank you for the video. I am following your tutorial however I hit a wall with this error "Error: Cannot find module 'graphql'" when trying to run the server. Thank you ... Please help
Amazing Course! Thanks a ton!
Creating and handling all user creation logic manually is such a pain, are there no pre-build methods for that?
Great tutorial, super useful stuff! It's nice that you remote the password from the return data at 14:43, however, later on when you add the relations and possibility to viewing events and bookings, it's possible to step in to the Creator property and access the password (although hashed) that way. Would you have a suggestion on how to prevent returning the password at all times?
i think you can remove password field from User, but keep this in UserInput; work from me
Thanks for the great tutorials, Max. I’m just curious why everyone still uses -save when they npm install things. Hasn’t it saved to package.json by default for a while now?
True - I'm just used to adding this. And for tutorials, I like to add it for clarity, too. It really makes it easier (hopefully) to differentiate dev and prod dependencies.
Very happy to read that, thanks so much for this great feedback!
Hi Max! Thank you for your videos! Wouldn't be cleaner for your resolvers if you push a created event's id in createdEvents array on eventSchema.post("save",...)?
Thanks for the tutorials Max, brilliant as always. Would you be using "react-apollo" for the front-end?
Hi Max, thank you for all your effort. This is such a useful as usual.
May I ask you to add this episode and the previous one into the playlist?
Best Regards,
Balazs
Thanks a lot for your great feedback and for the hint Balazs, I added the videos to the playlist!
{
"errors": [
{
"message": "Cannot read property 'push' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createEvent"
]
}
],
"data": {
"createEvent": null
}
}
this error came?
I have the same problem...
Maybe a little late, but try to remove the return { ...result._doc }; underneath the return User.findById line and make sure that the user id in the code matches the user id in the mongodb.
I am not able to connect to MongoDB database and getting below error.
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} }
[nodemon] clean exit - waiting for changes before restart
Use the Long SRV string from mongoDb while connecting the application, there are some problem with the short one. Hope it helps!
I had the same issue and figured out you need to do the IP whitelist step again.
how to do that ?
@@patel2776 From the Clusters view, select the Security tab, then click IP Whitelist.
Sometimes, get the current IP address function in the Mongo console does not return your correct IP. You can get the IP address by yourself and add there. At least, that's what i did, and it worked.
Thoughts for including kubernetes (minikube)
Instead of checking if a user with same email id exists... maybe we just set email as index: true ?
I'm use sequelize on sql and for the email verification have a property of relational db name unique and verified that, nice video series liked a lot (y)
Can i also validate through my model using "unique: true" on the users email address or are there differences?
hm, okay unique: true seems to handle something else. unique indexes i guess (?)
@@sebastianjung3168 "unique: true" works for unique value validation as expected, and we avoid the extra "User.findOne()" search. You can also use mongoose-unique-validator plugin to return a friendlier error message.
excellent course, practice promises alot )
Great episode learnt alot
Happy to read that Ravi!
Creating a new user. gives me following error
"ReferenceError: event is not defined" .
will someone kindly help
Also looking for this answer
Great series!
hi, Alex! Have you plan to publish video free or paid with graphql authentication jwt, pagination, validation?
what about User.findByIdAndUpdate ?
How many episodes you plan to do?
I got no plan, I haven't finished recording the series yet.
Err : Cannot GET /graphql
Help please
Does it bother anyone else that your schema is just a template string? That’s the only thing I don’t like about GraphQL so far. I keep feeling like I’m doing it wrong
awesome Max, thanks
why use bcrypt.js instead of bcrypt?
Can you make a compare video on django and node.js or express
thank you so so much.
so finally completed task after to mess ... yes Max is good teacher but sometimes to confuse me
Thanks
why did he set type as Schema.Types.ObjectId ??
Because the objects are stored based on their ids
Wth is up with multiple return on same block. Holy bananas i was following fine until this point O.O
When I reload the localhost:3000/graphql page ! it doesnt work anymore ! with no console Error !!!
Thank you
Thanks!!
Thank you for the video
I just want to add that instead of checking if the user already existed we can do the following in the model
email: {
type: String,
unique: true,
// this will make sure that there will be no duplicate email
required: [true, 'An email is required for a user'],
},
password: {
type: String,
required: [true, 'A password is required for a user'],
select: false,
// this wont return the password when we query for it
},
i tried this with the unique key, but i doesn't work for me
First thank you very much, I really appreciate this. Second, please post the full course at once. I'm not sure about what is your market strategy here, but on our side though, at times our job will let us allocate a chunk of time on the side to learn a new tech. Your tutorial is great but it's counterproductive and less likely that I can convince my boss to make random stops and wait to whenever you post your next video. I'm sure I'm not the only one on this boat here...
Thank you for your great feedback and for your suggestion Tonki!
Releasing the videos step-by-step is an additional service for all of you (besides the fact that this series is 100% for free) as I'm still recording the videos and I want to make sure you can access the videos as fast as possible. You always have the option to wait until the entire series is released, but then you have to wait a bit - that's kind of the deal.
@@academind Thank you so much Max.
Dude, I think you should have just stopped at "Thank you" I can't imagine why you feel you are entitled to demand the videos to be put out in the way you want.
@@Iamdigitalsleep no one feels entitled to anything here and there's no demand. just feedback. which you could use some as well 😉
I love all your courses in Udemy except Udemy app stop supporting older iPad.
Promises hell
Aren't there foreign keys in mongodb? Why can we not simply have the creator field on the events collection and be done with it? You no longer have a single source of truth with the current approach.
you're a beautiful man
Thank you :)
X-MEN x-programmer