vektah / dataloaden

go generate based DataLoader
MIT License
530 stars 79 forks source link

Order of Results #2

Closed Teddy-Schmitz closed 6 years ago

Teddy-Schmitz commented 6 years ago

Hi,

I wanted to double check that if the order of results returned from the database matter. For example postgres doesn't guarantee the order of results when doing an IN query and looking through the generated code it looks like it expects the results to match the order of the keys it sends.

If it does, any thoughts on what the best practice should be here. Maybe the fetch function should return a map[keys]values instead of a slice?

Thanks!

vektah commented 6 years ago

Yep the order is important, you should find the Id in the set and put it in the correct place.

I guess that's a bug in my example code too.

I'll update it and ping here when it's done. Probably won't be for a day or two.

Teddy-Schmitz commented 6 years ago

appreciate it! Thanks again for two really great libraries.

Teddy-Schmitz commented 6 years ago

@vektah we came up with our own solution for this but if you have time I would like to see how you would accomplish this.

vektah commented 6 years ago

Wow that was a long "day or two"

Hows this look @Teddy-Schmitz https://github.com/vektah/gqlgen-tutorials/commit/cfe52b1e4ba43164429a1d47e902c160727fc4c2?

Teddy-Schmitz commented 6 years ago

thanks for this will take a look

nii236 commented 5 years ago

@Teddy-Schmitz I just ran into this issue and keen to see how you solved it on your end if you have a snippet you can share.