Using DataLoader to Avoid N+1 Queries in GraphQL

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 41

  • @melpacheco9288
    @melpacheco9288 4 года назад +3

    I love this channel, always practical examples.

    • @leighhalliday
      @leighhalliday  4 года назад

      Thanks, Mel :) I appreciate it. N+1 in GraphQL can kill your performance like nothing else!

  • @larube
    @larube 4 года назад

    Looks good to work with early 2000's hardcore albums !

    • @leighhalliday
      @leighhalliday  4 года назад

      Nothing is better for coding!

    • @larube
      @larube 4 года назад

      ​@@leighhalliday That's right !

  • @VincentFulco
    @VincentFulco 4 года назад

    You create terrific videos even stuff relative noob can understand.

  • @PatrikRasch
    @PatrikRasch 11 месяцев назад

    Good stuff

  • @melpacheco9288
    @melpacheco9288 4 года назад +2

    Hey man, did you ever do the video loading multiple records?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hehe... no I didn't :D I actually wrote an article about it using Ruby on Rails pganalyze.com/blog/efficient-graphql-queries-in-ruby-on-rails-and-postgres but the truth is that I don't maintain any sort of production node based GraphQL API, so I haven't been deep into this stuff. My apologies!

    • @melpacheco9288
      @melpacheco9288 4 года назад

      @@leighhalliday no worries, your content is always relevant, and you always use great examples. looking forward to the next video!

  • @rabbyhossain6150
    @rabbyhossain6150 2 года назад

    Suppose, I want to display two artist names for each album and for this what should be the query?

  • @arobmusicful
    @arobmusicful 4 года назад

    Comeback Kid!! Hell yeah!

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Wake the silence, wake the dead!

    • @arobmusicful
      @arobmusicful 4 года назад

      Great video! Nice to see a thorough explanation of this issue and a bonus to see another dev down with the core!! (I come from that scene and have been getting into development over the past year, so this is the best of both worlds! Lol)

  • @chongma
    @chongma 2 года назад

    Thank you

  • @ogbillity
    @ogbillity 3 года назад

    Hello, Leigh thank you for this tutorial. How do pass user alongside the loader in the context. I am trying to handle authentication and authorization.

    • @leighhalliday
      @leighhalliday  3 года назад

      Hey Peter! I believe you'd have to load the user within the context function here: github.com/leighhalliday/nextjs-graphql-example/blob/dataloader/pages/api/graphql.js#L112

  • @sebastian5100630
    @sebastian5100630 3 года назад

    Hello Leigh i have a ques, if i have a type like this
    type Order {
    total
    qtity
    createdAt
    user {
    id
    name
    }
    client {
    id
    name
    }
    }
    this single loader still work?

    • @leighhalliday
      @leighhalliday  3 года назад

      You would use a User loader and a Client loader

  • @Rimteh33
    @Rimteh33 4 года назад

    Hey Leigh, could you help me out to solve this issue using nexus for schema definitions?

    • @leighhalliday
      @leighhalliday  4 года назад

      Hey Aleksej! I'd love to but I honestly am so strapped for time I don't think I can look into this... barely holding on as is.

    • @Rimteh33
      @Rimteh33 4 года назад

      @@leighhalliday I totally understand. Do you have some useful references?

  • @pyfreelancer5527
    @pyfreelancer5527 3 года назад

    thanks

  • @AliYasir5247
    @AliYasir5247 4 года назад

    in the video its mentioned more advance dataloader usecases?

    • @leighhalliday
      @leighhalliday  4 года назад

      Coming at some point in the future :D I want to cover the topics I covered in my article here, but do them in Node (article is about Ruby on Rails). pganalyze.com/blog/efficient-graphql-queries-in-ruby-on-rails-and-postgres

  • @erenkarahasan6834
    @erenkarahasan6834 3 года назад

    Thanks for the insightful video
    Where is the link mentioned at 3:19 tho? :)

    • @leighhalliday
      @leighhalliday  3 года назад +1

      Haha... I honestly have no idea. Here's one that may help though :) ruclips.net/video/_HOp7hBEjp8/видео.html

  • @behindthescenex
    @behindthescenex 4 года назад

    Hi leigh thank you so much for the lesson! 😭🙏🏼 I want to ask, if i want to load 100 records in a single request, is it possible to cache them when using dataloader ?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Thanks, Gede! What do you mean cache them? So that on the following API request DataLoader doesn't have to fetch a record it has already loaded? I suppose it is... but you'd have to save it somewhere, right? If you save it in memory, you'd want to make sure that it doesn't bloat too much, if you save it in Redis, you'd be required to do 1 request to Redis then 1 request to Postgres to fetch remaining... so you may find it's just easier to avoid thinking about caching until it becomes an issue.

    • @behindthescenex
      @behindthescenex 4 года назад

      @@leighhalliday Yes thats the idea, i dont have to re-fetch the data again if i already load it once. Thank you so much for the tip leigh. I'll try your redis suggestion. This tutorial helped me a lot on my final exam 🙏🏼🙏🏼

  • @PavanMehta
    @PavanMehta 3 года назад

    It's from facebook indeed!

  • @MoT-MasterOfThings
    @MoT-MasterOfThings 4 года назад

    Why video quality is not higher than 360p

    • @leighhalliday
      @leighhalliday  4 года назад +1

      RUclips is still processing the HD versions... just finished uploading. They publish SD first and then HD when it's ready. Wait like 30 minutes and it should be good.

    • @dru284
      @dru284 4 года назад +1

      Great work Leigh!

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Thanks Andrew!

  • @jeresalem
    @jeresalem 4 года назад

    Or just use Hasura ☺️

    • @leighhalliday
      @leighhalliday  4 года назад +1

      I've been meaning to try that out! Looks really cool.