mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

Use graphql-sequelize with dataloader-sequelize #718

Closed hhoangg closed 1 year ago

hhoangg commented 1 year ago

I have a problem with dataloader-sequelize Example: I have two Model User and File, Model File BelongTo User (User 1-n File) When I use Graphql to findAll Model File and get field user then Sequelize executes n times findOne User to map with File, but I want to use dataloader to findAll once and map data for each file to up performance. Below is my code, please help me.

import { resolver } from "graphql-sequelize";
File = {
  user = resolver(File.associations.user)
}
mickhansen commented 1 year ago

@hhoangg Please provide more reference code and take a look at the test suite: https://github.com/mickhansen/graphql-sequelize/tree/master/test

hhoangg commented 1 year ago

I found a solution at here, actually, I have seen it before, but due to the wrong integration, it led to the above problem, sorry for opening the topic, Please allow me to close the topic here, thank you helped