Skip to content

Commit

Permalink
Fix bug with null result for federated objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreeden-splunk committed Mar 27, 2020
1 parent 36f99c5 commit f23e3c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ func executorFindInsertionPoints(resultLock *sync.Mutex, targetPoints []string,
// get the type of the object in question
selectionType := foundSelection.Definition.Type

if rootValue == nil {
if selectionType.NonNull {
err := fmt.Errorf("Received null for required field: %v", foundSelection.Name)
log.Warn(err)
return nil, err
} else {
return nil, nil
}
}

// if the type is a list
if selectionType.Elem != nil {
log.Debug("Selection should be a list")
Expand Down
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (g *Gateway) GraphQLHandler(w http.ResponseWriter, r *http.Request) {
// fire the query with the request context passed through to execution
result, err = g.Execute(requestContext, plan)
if err != nil {
results = append(results, formatErrorsWithCode(nil, err, "INTERNAL_SERVER_ERROR"))
results = append(results, formatErrorsWithCode(result, err, "INTERNAL_SERVER_ERROR"))
continue
}

Expand Down

0 comments on commit f23e3c8

Please sign in to comment.