resolveNestedFields resolves fields which themselves don't have the @custom directive but their children might. queryUser { id classes { name @custom... } } In the example above, resolveNestedFields would be called on classes field and parentNodeHeads would be the list of head pointers
(childField gqlSchema.Field, parentNodeHeads []fastJsonNode, wg *sync.WaitGroup)
| 1014 | // In the example above, resolveNestedFields would be called on classes field and parentNodeHeads |
| 1015 | // would be the list of head pointers for all the user fastJson nodes. |
| 1016 | func (genc *graphQLEncoder) resolveNestedFields(childField gqlSchema.Field, |
| 1017 | parentNodeHeads []fastJsonNode, wg *sync.WaitGroup) { |
| 1018 | defer wg.Done() // signal when this goroutine finishes execution |
| 1019 | |
| 1020 | var childNodeHeads []fastJsonNode |
| 1021 | var parentNodeHeadAttr uint16 |
| 1022 | if len(parentNodeHeads) > 0 { |
| 1023 | parentNodeHeadAttr = genc.getAttr(parentNodeHeads[0]) |
| 1024 | } |
| 1025 | childFieldAttr := genc.idForAttr(childField.DgraphAlias()) |
| 1026 | // iterate over all the parentNodeHeads and build the list of childNodeHeads for this childField |
| 1027 | for _, parentNodeHead := range parentNodeHeads { |
| 1028 | // iterate over all the siblings of this parentNodeHead which have the same attr as this |
| 1029 | for parentNode := parentNodeHead; parentNode != nil && genc.getAttr( |
| 1030 | parentNode) == parentNodeHeadAttr; parentNode = parentNode.next { |
| 1031 | // find the first child node which has data for childField |
| 1032 | fj := genc.children(parentNode) |
| 1033 | for ; fj != nil && genc.getAttr(fj) != childFieldAttr; fj = fj.next { |
| 1034 | // do nothing, just keep skipping unnecessary data |
| 1035 | } |
| 1036 | if fj != nil { |
| 1037 | // we found the first node that has data for childField, |
| 1038 | // add that node to the list of childNodeHeads |
| 1039 | childNodeHeads = append(childNodeHeads, fj) |
| 1040 | } |
| 1041 | } |
| 1042 | } |
| 1043 | // if we found some data for the child field, then only we need to |
| 1044 | // resolve the custom fields in the selection set of childField |
| 1045 | if len(childNodeHeads) > 0 { |
| 1046 | genc.resolveCustomFields(childField.SelectionSet(), childNodeHeads) |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | // completeRootAggregateQuery builds GraphQL JSON for aggregate queries at root. |
| 1051 | // Root aggregate queries return a single object of type `TypeAggregateResult` which contains the |
no test coverage detected