vikstrous / dataloadgen

An implementation of Facebook's DataLoader in Go
MIT License
60 stars 10 forks source link

Loading values which do not have comparable indices #13

Open KevinJTaylor opened 4 months ago

KevinJTaylor commented 4 months ago

Basically it is difficult to create a loader for an index which is not comparable such as github.com/google/uuid. I believe I need to convert the uuid to/from a string and when loading data (via a query), unless I am missing something?

Loader[KeyT comparable, ValueT any]

NewLoader[KeyT comparable, ValueT any](...)
vikstrous commented 3 months ago

The keys have to be comparable because they are used as map keys to deduplicate requests. But the uuid type is [16]byte, so it should be comparable https://pkg.go.dev/github.com/google/uuid#UUID. Which type are you running into issues with?