DefaultResolveFn works properly for the following maps:
type MyMap map[string]any
but when we change the map key:
type MyKey string
type MyMap map[MyKey]any
it returns the following errors:
reflect.Value.MapIndex: value of type string is not assignable to type .*
Example:
Error
2009/11/10 23:00:00 failed to execute graphql operation, errors: [reflect.Value.MapIndex: value of type string is not assignable to type main.TranslationKey reflect.Value.MapIndex: value of type string is not assignable to type main.TranslationKey]
Issue
DefaultResolveFn
works properly for the following maps:but when we change the map key:
it returns the following errors:
Example:
Error
Code
https://go.dev/play/p/giPGGUxKht8
Solution
The following PR solves that problem, but I believe it's been wrongly closed.
https://github.com/graphql-go/graphql/pull/697
Please take a look at the deeper explanation in the comment https://github.com/graphql-go/graphql/pull/697#issuecomment-2385949145