#6 Adding Relations | Build a Complete App with GraphQL, Node.js, MongoDB and React.js

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 125

  • @sleeplessdev7204
    @sleeplessdev7204 5 ปีที่แล้ว +3

    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! ❤️

    • @academind
      @academind  5 ปีที่แล้ว

      Thanks a million for this fantastic feedback, reading this honestly means a lot to me!

  • @atAnkitMurarka
    @atAnkitMurarka 5 ปีที่แล้ว +1

    I like this series because there is no previously written code. Everything is written from scratch and each line of code is explained.

  • @pprathameshmore
    @pprathameshmore 4 ปีที่แล้ว +1

    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.

  • @vzsshadow3141
    @vzsshadow3141 5 ปีที่แล้ว

    i don't got why someone hit dislike to this video because this is a very clear video for anybody :)

    • @academind
      @academind  5 ปีที่แล้ว

      Always hard to make everybody happy I guess, but it's just great to get the support from you and so many others :)

  • @alexjoe3267
    @alexjoe3267 5 ปีที่แล้ว +2

    I was so lost with GraphQL, thank you for this tutorial.

  • @Tusharchutani
    @Tusharchutani 6 ปีที่แล้ว +42

    Since there are so many promisese and there are so many .thens shouldn't we just use async await?

    • @academind
      @academind  6 ปีที่แล้ว +37

      We will soon

    • @N96123
      @N96123 5 ปีที่แล้ว +3

      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 ?

    • @vikrantsingh47
      @vikrantsingh47 5 ปีที่แล้ว

      @@N96123 wow this is much more cleaner and readable

    • @donmutua1739
      @donmutua1739 5 ปีที่แล้ว

      thought the same...

    • @himujjalupadhyaya6157
      @himujjalupadhyaya6157 5 ปีที่แล้ว

      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.

  • @Iamdigitalsleep
    @Iamdigitalsleep 6 ปีที่แล้ว +1

    Thanks for the series , I really appreciate you putting all the effort in putting this together .

    • @academind
      @academind  6 ปีที่แล้ว

      Thank YOU for your comment Shawn, happy to read that you like it!

  • @mattcroat
    @mattcroat 5 ปีที่แล้ว +4

    🔴 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!

    • @swathir3014
      @swathir3014 4 ปีที่แล้ว

      thank you so much!!! i was struggling to find the solution

  • @Majik_exe
    @Majik_exe 3 ปีที่แล้ว +2

    My Brain is fried after all those thens

  • @samb.4260
    @samb.4260 5 ปีที่แล้ว

    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.

  • @khalidkhan5308
    @khalidkhan5308 5 ปีที่แล้ว

    This is one of the best channel on youtube !

    • @academind
      @academind  5 ปีที่แล้ว

      Thanks a lot Khalid, this really means a lot to us!

  • @altcoelho
    @altcoelho 6 ปีที่แล้ว +24

    My Head is spinning to why we are going into promise chain hell as opposed to *async await* . Thoughts?

    • @JoeWong81
      @JoeWong81 6 ปีที่แล้ว +3

      I agree. It's too difficult to follow along near the end especially for beginners like me

    • @GooseGumlizzard
      @GooseGumlizzard 4 ปีที่แล้ว

      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

    • @zoroXgamings
      @zoroXgamings 3 ปีที่แล้ว

      @@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);
      }
      },

  • @Aykoo
    @Aykoo 5 ปีที่แล้ว

    Learned so much from just one video... Danke für dieses wundervolle Vid!

    • @academind
      @academind  5 ปีที่แล้ว

      Vielen Dank Aykut :)

  • @DjSkywalkerz
    @DjSkywalkerz 5 ปีที่แล้ว

    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.

  • @rtorcato
    @rtorcato 6 ปีที่แล้ว +2

    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'
    }

    • @rtorcato
      @rtorcato 6 ปีที่แล้ว +4

      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'],
      },

    • @okomi
      @okomi 4 ปีที่แล้ว

      @@rtorcato you wouldnt be by some chance willing to make a video about it right?

  • @psykoj
    @psykoj 4 ปีที่แล้ว

    Great tutorial series! Thank you for putting these together!

  • @hamzakhattabi9251
    @hamzakhattabi9251 5 ปีที่แล้ว +4

    More easily and readable with async await, but good tutorial :D

  • @yannsalmon4074
    @yannsalmon4074 4 ปีที่แล้ว

    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 ?

  • @mohammedabahussain3366
    @mohammedabahussain3366 3 ปีที่แล้ว

    Amazing tutorial, I had a confusion with relations in mongoose but you cleared it out thanks a lot :)

  • @balporsugu7198
    @balporsugu7198 4 ปีที่แล้ว +2

    Trying to scroll up and down in app.js is frustrating. I wish it was started in seperate files.

  • @lipi6535
    @lipi6535 4 ปีที่แล้ว

    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!!

  • @khemirimonem6001
    @khemirimonem6001 4 ปีที่แล้ว

    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 ?

  • @michaelzucker772
    @michaelzucker772 6 ปีที่แล้ว +2

    Great series Max! Thank you for all the energy and effort you put into creating these! (And your Udemy courses are tops too!)

    • @academind
      @academind  6 ปีที่แล้ว

      Thanks a lot Michael, great to read that you like my TH-cam videos and Udemy courses :)

  • @MrMaksuz
    @MrMaksuz 4 ปีที่แล้ว +1

    why not using await syntax ?

  • @reyshinryu
    @reyshinryu 4 ปีที่แล้ว

    THANK U SO SO SO MUCH MAX!!!!!!! sorry for the spam but this tutorial is exactly what i've been looking for!!!

  • @alex_7892m
    @alex_7892m 5 ปีที่แล้ว

    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.

  • @akash-kumar737
    @akash-kumar737 5 ปีที่แล้ว

    Adding createdEvents field in user seems to me unnecessary. Do let me know if you feel that is required?

  • @ksgj2000
    @ksgj2000 5 ปีที่แล้ว +1

    Thank you Max this series really helpful!!!

  • @sNineMM
    @sNineMM 6 ปีที่แล้ว +1

    Thank you Max, great content as always.

    • @academind
      @academind  6 ปีที่แล้ว

      Happy to read that you like the video Jamille, thank you!

  • @gosnooky
    @gosnooky 5 ปีที่แล้ว +1

    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

  • @abdulhafizahmed6389
    @abdulhafizahmed6389 5 ปีที่แล้ว

    Thanks for the tutorial. I am coding-along while using sequelize and postgresql.

  • @kartikmalik4943
    @kartikmalik4943 4 ปีที่แล้ว

    We are retuning "creator" in createEvent but didn't specify it in "type event", So is that correct?

  • @lesterlugtu4090
    @lesterlugtu4090 4 ปีที่แล้ว

    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.

  • @jacobniivanderpuye7869
    @jacobniivanderpuye7869 5 ปีที่แล้ว

    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

  • @sanskaarpatni9137
    @sanskaarpatni9137 4 ปีที่แล้ว

    Amazing Course! Thanks a ton!

  • @boryskuczkowski
    @boryskuczkowski 5 ปีที่แล้ว

    Creating and handling all user creation logic manually is such a pain, are there no pre-build methods for that?

  • @surf679
    @surf679 5 ปีที่แล้ว

    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?

    • @moedor007
      @moedor007 5 ปีที่แล้ว +1

      i think you can remove password field from User, but keep this in UserInput; work from me

  • @riongull
    @riongull 6 ปีที่แล้ว +2

    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?

    • @academind
      @academind  6 ปีที่แล้ว

      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.

    • @academind
      @academind  6 ปีที่แล้ว

      Very happy to read that, thanks so much for this great feedback!

  • @ioannispotouridis297
    @ioannispotouridis297 6 ปีที่แล้ว

    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",...)?

  • @fortunatoherrera9064
    @fortunatoherrera9064 5 ปีที่แล้ว

    Thanks for the tutorials Max, brilliant as always. Would you be using "react-apollo" for the front-end?

  • @19balazs86
    @19balazs86 6 ปีที่แล้ว

    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

    • @academind
      @academind  6 ปีที่แล้ว +1

      Thanks a lot for your great feedback and for the hint Balazs, I added the videos to the playlist!

  • @userasd360
    @userasd360 4 ปีที่แล้ว +1

    {
    "errors": [
    {
    "message": "Cannot read property 'push' of undefined",
    "locations": [
    {
    "line": 2,
    "column": 3
    }
    ],
    "path": [
    "createEvent"
    ]
    }
    ],
    "data": {
    "createEvent": null
    }
    }
    this error came?

    • @johnpettyfer1926
      @johnpettyfer1926 3 ปีที่แล้ว

      I have the same problem...

    • @anders8638
      @anders8638 ปีที่แล้ว

      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.

  • @patel2776
    @patel2776 5 ปีที่แล้ว +1

    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

    • @shub0y
      @shub0y 5 ปีที่แล้ว

      Use the Long SRV string from mongoDb while connecting the application, there are some problem with the short one. Hope it helps!

    • @mattcroat
      @mattcroat 5 ปีที่แล้ว

      I had the same issue and figured out you need to do the IP whitelist step again.

    • @patel2776
      @patel2776 5 ปีที่แล้ว

      how to do that ?

    • @mattcroat
      @mattcroat 5 ปีที่แล้ว

      @@patel2776 From the Clusters view, select the Security tab, then click IP Whitelist.

    • @naveencooray2733
      @naveencooray2733 5 ปีที่แล้ว

      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.

  • @mojalefatsoaeli4367
    @mojalefatsoaeli4367 6 ปีที่แล้ว

    Thoughts for including kubernetes (minikube)

  • @AshutoshRautela
    @AshutoshRautela 5 ปีที่แล้ว

    Instead of checking if a user with same email id exists... maybe we just set email as index: true ?

  • @fan1ortiz
    @fan1ortiz 5 ปีที่แล้ว

    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
    @sebastianjung3168 5 ปีที่แล้ว

    Can i also validate through my model using "unique: true" on the users email address or are there differences?

    • @sebastianjung3168
      @sebastianjung3168 5 ปีที่แล้ว

      hm, okay unique: true seems to handle something else. unique indexes i guess (?)

    • @chrismerkand
      @chrismerkand 5 ปีที่แล้ว

      @@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.

  • @ivanivanov144
    @ivanivanov144 5 ปีที่แล้ว

    excellent course, practice promises alot )

  • @Raviraj-1514
    @Raviraj-1514 6 ปีที่แล้ว

    Great episode learnt alot

    • @academind
      @academind  6 ปีที่แล้ว

      Happy to read that Ravi!

  • @shahmirjadoon1322
    @shahmirjadoon1322 4 ปีที่แล้ว

    Creating a new user. gives me following error
    "ReferenceError: event is not defined" .
    will someone kindly help

  • @allaheadflank
    @allaheadflank 6 ปีที่แล้ว

    Great series!

  • @grigorischaram3216
    @grigorischaram3216 6 ปีที่แล้ว

    hi, Alex! Have you plan to publish video free or paid with graphql authentication jwt, pagination, validation?

  • @parrou3
    @parrou3 6 ปีที่แล้ว

    what about User.findByIdAndUpdate ?

  • @Iwillownyouandbehappy
    @Iwillownyouandbehappy 6 ปีที่แล้ว

    How many episodes you plan to do?

    • @academind
      @academind  6 ปีที่แล้ว +2

      I got no plan, I haven't finished recording the series yet.

  • @MrBibou23ca
    @MrBibou23ca 5 ปีที่แล้ว

    Err : Cannot GET /graphql
    Help please

  • @christophercaldwell6641
    @christophercaldwell6641 4 ปีที่แล้ว

    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

  • @laksana29
    @laksana29 5 ปีที่แล้ว

    awesome Max, thanks

  • @GooseGumlizzard
    @GooseGumlizzard 4 ปีที่แล้ว

    why use bcrypt.js instead of bcrypt?

  • @mahmudulhussain5401
    @mahmudulhussain5401 6 ปีที่แล้ว +2

    Can you make a compare video on django and node.js or express

  • @truongnguyenvan9050
    @truongnguyenvan9050 4 ปีที่แล้ว

    thank you so so much.

  • @ravinwashere
    @ravinwashere 5 ปีที่แล้ว

    so finally completed task after to mess ... yes Max is good teacher but sometimes to confuse me

  • @maryamfalahsafari8368
    @maryamfalahsafari8368 3 ปีที่แล้ว

    Thanks

  • @ammarhalees6370
    @ammarhalees6370 5 ปีที่แล้ว

    why did he set type as Schema.Types.ObjectId ??

    • @pulkitsharma9945
      @pulkitsharma9945 3 ปีที่แล้ว

      Because the objects are stored based on their ids

  • @nikossenounta4584
    @nikossenounta4584 5 ปีที่แล้ว +1

    Wth is up with multiple return on same block. Holy bananas i was following fine until this point O.O

  • @MrBibou23ca
    @MrBibou23ca 5 ปีที่แล้ว

    When I reload the localhost:3000/graphql page ! it doesnt work anymore ! with no console Error !!!

  • @saisreenivas2227
    @saisreenivas2227 6 ปีที่แล้ว

    Thank you

  • @INKWEON7269
    @INKWEON7269 6 ปีที่แล้ว

    Thanks!!

  • @MrKentiba
    @MrKentiba 5 ปีที่แล้ว +1

    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
    },

    • @pangiolillo
      @pangiolillo 4 ปีที่แล้ว

      i tried this with the unique key, but i doesn't work for me

  • @tonkihonks3430
    @tonkihonks3430 6 ปีที่แล้ว +3

    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...

    • @academind
      @academind  6 ปีที่แล้ว +11

      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.

    • @tonkihonks3430
      @tonkihonks3430 6 ปีที่แล้ว

      @@academind Thank you so much Max.

    • @Iamdigitalsleep
      @Iamdigitalsleep 6 ปีที่แล้ว +5

      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.

    • @tonkihonks3430
      @tonkihonks3430 6 ปีที่แล้ว

      @@Iamdigitalsleep no one feels entitled to anything here and there's no demand. just feedback. which you could use some as well 😉

  • @triTube70
    @triTube70 3 ปีที่แล้ว

    I love all your courses in Udemy except Udemy app stop supporting older iPad.

  • @neiker234
    @neiker234 5 ปีที่แล้ว +1

    Promises hell

  • @DoktorKumpel
    @DoktorKumpel 5 ปีที่แล้ว

    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.

  • @jacas_
    @jacas_ 5 ปีที่แล้ว

    you're a beautiful man

    • @academind
      @academind  5 ปีที่แล้ว

      Thank you :)

  • @gravityarm9240
    @gravityarm9240 5 ปีที่แล้ว

    X-MEN x-programmer