Request to reintroduce Key/Keys interfaces#93
Request to reintroduce Key/Keys interfaces#93sGy1980de wants to merge 5 commits intograph-gophers:masterfrom
Conversation
|
Вad idea, in go v1.18+ comparable is just used to describe key types that you can compare. All other libraries support this paradigm and if you rewrite the library to [any, any] you can get a lot of integration problems. We have the same problem too, but we go to another way. U can use some comparable interface and struct (go v1.20). type Key[K comparable] interface{
Raw() K
String() string
}You can see my code eaglemoor#1 . In it, I'm trying to fix 2 problems:
|
And exactly this is my problem. My identifier contain types, considered not @pavelnikolov This would for sure mean some major code-duplication, which could be somewhat addressed by static code generation. But I would not like to invest the effort, if this has zero chance, to be merged upstream. |
|
I'm happy to go with an interface or other solution but I want to understand the problem first. Could you, please, give me a very minimalistic example which is broken or doesn't work. |
|
ping |
Hey guys,
we at esome really love your work. When we wanted to update this lib to
v7, we stumbled over one problem. In our scenario, we use the data-loader to optimize our SQL queries also for parametrized GraphQL edges.Therefore, our current keys do not fulfill the
comparableconstraint. With theKeyinterface, this wasn't a problem, since our keys simply exported a unique identifier according to their parameters.That's why I took a step back, and reintroduced the
Keyinterface backed with type parameters this time. So, basically the best from both worlds. Please let me know what you think about it. I'm not sure, about the parameter in theBatchFuncthough, but I decided to keep the API clean (Key/Keys everywhere) in the first place. But this might be subject to change, since there is no real need for theKeythere.