ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.16k stars 735 forks source link

Document UseDataLoader() #4631

Open mausch opened 2 years ago

mausch commented 2 years ago

Is your feature request related to a problem?

UseDataLoader was added in https://github.com/ChilliCream/hotchocolate/issues/2505 but there doesn't seem to be any documentation around it.

The solution you'd like

Document it maybe here? https://chillicream.com/docs/hotchocolate/fetching-data/dataloader

Product

Hot Chocolate

michaelstaib commented 2 years ago

Do you want to do a pull request?

mausch commented 2 years ago

Hi, I'm new to HotChocolate, that's why I'm asking about this documentation :slightly_smiling_face:

MarkoH17 commented 2 years ago

I am curious about the DataLoader middleware too. The graphql-workshop repository mentions (just above this) in session 6 that using a resolver alongside a dataloader causes paging to happen in memory:

There is one caveat in our implementation with the TrackType. Since, we are using a DataLoader within our resolver and first fetch the list of IDs we essentially will always fetch everything and chop in memory. In an actual project this can be split into two actions by moving the DataLoader part into a middleware and first page on the id queryable. Also one could implement a special IPagingHandler that uses the DataLoader and applies paging logic.

Would UseDataLoader() middleware resolve this inefficiency?

MarkoH17 commented 2 years ago

I believe this is still relevant. I have been unable to find documentation on UseDataLoader, which seems like a key component in stacking middlwares for custom resolvers.

@michaelstaib, can you shed some light on how this method should be used?