Data Loaders (the N+1 problem) - GRAPHQL API IN .NET w/ HOT CHOCOLATE #6

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

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

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

    Man, you've just saved my day! I finally got this to work, which I couldn't after reading all of official documentation >_

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

    Hi Sean, excellent content. I was wondering if you could explain in future videos how to implement one to many relationships with HotChocolate.

  • @surenhovakimyan9649
    @surenhovakimyan9649 7 หลายเดือนก่อน

    Hi Sean.
    Excellent tutorials.
    Could you please tell how to setup mock data for InstructorType with Bogus in case if we use InstructorDataLoader ?

  • @takihdruzei
    @takihdruzei 2 ปีที่แล้ว +1

    Hi, question, for data loaders if you use projection does the GQL selects all the fields from the database, or when you use DataLoaders projections does not work?

  • @namanvohra8262
    @namanvohra8262 2 ปีที่แล้ว +1

    Hey, really nice video, but could u please do this for one to many relations? Please, thanks a lot.

    • @SingletonSean
      @SingletonSean  2 ปีที่แล้ว

      Hey Naman, I'll make sure to do a one to many before the end of this series!

    • @namanvohra8262
      @namanvohra8262 2 ปีที่แล้ว

      @@SingletonSean Thanks for the reply Sean! I tried doing this with a one to many relation, but noticed that the resolver will still be called several number of times even though the call to database will only be once. I tried this in a normal scenario as well as in the case of schema stitching.

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

      @@SingletonSean any news from this?

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

      And a really nice video man!

    • @Silenc42
      @Silenc42 2 หลายเดือนก่อน

      @@aivalo I came across this now, about a year later. As far as I can tell the way to go is to use a GroupedDataLoader instead of a BatchDataLoader. I am using those in my project and it works like a charm.
      Technically, you can also groupBy and return a List instead of single objects, but the GroupedDataLoader takes most of it off your hand. Its nothing more than:
      DbContext..Where(e => keys.Contains(e.refId)).ToLookup(e => e.RefId);
      You can also squeeze in a mapping using .Select(MappingExpression) in between.