You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Returns true if a value is null, undefined, or NaN.
func isNullish(src interface{}) bool {
if src == nil {
return true
}
value := reflect.ValueOf(src)
if value.Kind() == reflect.Ptr {
value = value.Elem()
}
// [HERE] *** check for valid pointer
if !value.IsValid() {
return true
}
switch value.Kind() {
case reflect.String:
// if src is ptr type and len(string)=0, it returns false
if !value.IsValid() {
return true
}
case reflect.Int:
return math.IsNaN(float64(value.Int()))
case reflect.Float32, reflect.Float64:
return math.IsNaN(float64(value.Float()))
}
return false
}
// Returns true if src is a slice or an array
func isIterable(src interface{}) bool {
if src == nil {
return false
}
t := reflect.TypeOf(src)
// [HERE] *** unwrap the pointer
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
return t.Kind() == reflect.Slice || t.Kind() == reflect.Array
}
executor.go
func completeListValue(eCtx *executionContext, returnType *List, fieldASTs []*ast.Field, info ResolveInfo, result interface{}) interface{} {
resultVal := reflect.ValueOf(result)
// [HERE] *** Unwrap the pointer
if resultVal.Kind() == reflect.Ptr {
resultVal = resultVal.Elem()
}
parentTypeName := ""
The following unit test demonstrates the problem:
Expected functionality is that "test" is nil, instead, an error is generated:
The problem is that
isNullish()
doesn't look at the interface pointer types. Potentially you should do a:before the switch statement.
The text was updated successfully, but these errors were encountered: