Skip to content

Commit 338d828

Browse files
committed
Fix ci
1 parent e1bf8d6 commit 338d828

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

executor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,16 +996,18 @@ func DefaultResolveFn(p ResolveParams) (interface{}, error) {
996996
// Try accessing as map via reflection
997997
if r := reflect.ValueOf(p.Source); r.Kind() == reflect.Map && r.Type().Key().Kind() == reflect.String {
998998
fieldNameValue := reflect.ValueOf(p.Info.FieldName)
999-
mapKeyType := r.Type().Key()
1000999
// The map key type might be a string type alias and its underlying type is string,
10011000
// but it will be panic if we try to use it as a string value in `MapIndex`.
10021001
// So we need to convert the value of the field name to the map key type before
10031002
// using it as a map key.
10041003
//
10051004
// Related issue: https://github.com/graphql-go/graphql/issues/700
1006-
if !fieldNameValue.CanConvert(mapKeyType) {
1005+
//
1006+
// We cannot use `CanConvert` here since we need to be compatible with Go before 1.17.
1007+
if fieldNameValue.Kind() != reflect.String {
10071008
return nil, nil
10081009
}
1010+
mapKeyType := r.Type().Key()
10091011
fieldNameValue = fieldNameValue.Convert(mapKeyType)
10101012

10111013
val := r.MapIndex(fieldNameValue)

0 commit comments

Comments
 (0)