juffalow / express-graphql-example

Example project how to use Express and GraphQL. You can find working example with frontend at https://quotes.juffalow.com
https://graphql.juffalow.com/graphql
MIT License
248 stars 75 forks source link

Improve queries #14

Closed juffalow closed 4 years ago

juffalow commented 6 years ago

Because of #13 now it always loads everything from the database, even if it is not requested. This can be optimized also.

UmerIftikhar commented 6 years ago

Perhaps using dataloader could solve this issue. Example: https://github.com/facebook/dataloader/blob/master/examples/SQL.md Will look in to it sooner. :)

juffalow commented 6 years ago

If you will work with this, please let me know / share your observations.

UmerIftikhar commented 6 years ago

I created a new folder: loaders, where DataLoader functionality has been handled. You can check the changes on the forked repo. https://github.com/UmerIftikhar/express-graphql-sequelize-example

Changes have been made to the graphql/types/author.js file as well. It works like a charm now.

juffalow commented 6 years ago

Thank you! I will try it later today / this weekend.

juffalow commented 4 years ago

DataLoader added in b377d7b16708ee7f2c26f0529edb7e7a7c7e62de.