diff --git a/graphql/e2e/common/admin.go b/graphql/e2e/common/admin.go index da72091f102..0cba13594d7 100644 --- a/graphql/e2e/common/admin.go +++ b/graphql/e2e/common/admin.go @@ -29,6 +29,7 @@ import ( "github.com/dgraph-io/dgo/v200" "github.com/dgraph-io/dgo/v200/protos/api" "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/testutil" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" @@ -429,6 +430,34 @@ func health(t *testing.T) { } } +func partialHealth(t *testing.T) { + queryParams := &GraphQLParams{ + Query: `query { + health { + instance + status + group + } + }`, + } + gqlResponse := queryParams.ExecuteAsPost(t, graphqlAdminTestAdminURL) + RequireNoGQLErrors(t, gqlResponse) + testutil.CompareJSON(t, `{ + "health": [ + { + "instance": "zero", + "status": "healthy", + "group": "0" + }, + { + "instance": "alpha", + "status": "healthy", + "group": "1" + } + ] + }`, string(gqlResponse.Data)) +} + // The GraphQL /admin state result should be the same as /state func adminState(t *testing.T) { queryParams := &GraphQLParams{ diff --git a/graphql/e2e/common/common.go b/graphql/e2e/common/common.go index b4164599919..008e3e7a27a 100644 --- a/graphql/e2e/common/common.go +++ b/graphql/e2e/common/common.go @@ -213,6 +213,7 @@ func RunAll(t *testing.T) { // admin tests t.Run("admin", admin) t.Run("health", health) + t.Run("partial health", partialHealth) t.Run("state", adminState) t.Run("propagate client remote ip", clientInfoLogin) diff --git a/graphql/resolve/resolver.go b/graphql/resolve/resolver.go index 911730c9fd4..8cbb5d49a5e 100644 --- a/graphql/resolve/resolver.go +++ b/graphql/resolve/resolver.go @@ -1178,6 +1178,14 @@ func completeValue( return completeObject(path, field.SelectionSet(), val) case []interface{}: return completeList(path, field, val) + case []map[string]interface{}: + // This case is different from the []interface{} case above and is true for admin queries + // where we built the val ourselves. + listVal := make([]interface{}, 0, len(val)) + for _, v := range val { + listVal = append(listVal, v) + } + return completeList(path, field, listVal) default: if val == nil { if field.Type().ListType() != nil {