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

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ •

  • @denissmith8282
    @denissmith8282 2 роки тому +1

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

  • @katkatkatomg
    @katkatkatomg 2 місяці тому

    great video & tutorial!! small note for 2024: the [Service] attribute isn't necessary and in fact will break the batch loading functionality 😊

  • @XxTheMrProxX
    @XxTheMrProxX 2 роки тому +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 11 місяців тому

    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 2 роки тому

      @@SingletonSean any news from this?

    • @aivalo
      @aivalo 2 роки тому

      And a really nice video man!

    • @Silenc42
      @Silenc42 6 місяців тому +1

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