writeCustomField is used to write the value when the currentSelection is a custom field. If the current field had @custom(http: {...}), then we need to find the fastJson node which stores data for this field from the customNodes mapping, and use that to write the value for this field.
(curSelection gqlSchema.Field,
customNodes map[uint16]fastJsonNode, parentPath []interface{})
| 579 | // stores data for this field from the customNodes mapping, and use that to write the value |
| 580 | // for this field. |
| 581 | func (genc *graphQLEncoder) writeCustomField(curSelection gqlSchema.Field, |
| 582 | customNodes map[uint16]fastJsonNode, parentPath []interface{}) bool { |
| 583 | if cNode := customNodes[genc.idForAttr(curSelection.DgraphAlias())]; cNode != nil { |
| 584 | // if we found the custom fastJson node, then directly write the value stored |
| 585 | // in that, as it would have been already completed. |
| 586 | val, err := genc.getScalarVal(cNode) |
| 587 | if err == nil { |
| 588 | x.Check2(genc.buf.Write(val)) |
| 589 | // return true to indicate that the field was written successfully |
| 590 | return true |
| 591 | } |
| 592 | |
| 593 | // if there was an error getting the value, append the error |
| 594 | genc.errs = append(genc.errs, curSelection.GqlErrorf(append(parentPath, |
| 595 | curSelection.ResponseName()), "%s", err.Error())) |
| 596 | } |
| 597 | |
| 598 | // if no custom fastJson node was found or there was error getting the value, return false |
| 599 | return false |
| 600 | } |
| 601 | |
| 602 | func (genc *graphQLEncoder) initChildAttrId(field gqlSchema.Field) { |
| 603 | for _, f := range field.SelectionSet() { |
no test coverage detected