MCPcopy
hub / github.com/dgraph-io/dgraph / resolveCustomFields

Method resolveCustomFields

query/outputnode_graphql.go:705–723  ·  view source on GitHub ↗

resolveCustomFields resolves fields with custom directive. Here is the rough algorithm that it follows. queryUser { name @custom age school { name children class @custom { name numChildren } } cars @custom { name } } For fields with @custom directive 1. There w

(childFields []gqlSchema.Field,
	parentNodeHeads []fastJsonNode)

Source from the content-addressed store, hash-verified

703// For fields without custom directive we recursively call resolveCustomFields and let it do the
704// work.
705func (genc *graphQLEncoder) resolveCustomFields(childFields []gqlSchema.Field,
706 parentNodeHeads []fastJsonNode) {
707 wg := &sync.WaitGroup{}
708 for _, childField := range childFields {
709 if childField.Skip() || !childField.Include() {
710 continue
711 }
712
713 if childField.IsCustomHTTP() {
714 wg.Add(1)
715 go genc.resolveCustomField(childField, parentNodeHeads, wg)
716 } else if childField.HasCustomHTTPChild() {
717 wg.Add(1)
718 go genc.resolveNestedFields(childField, parentNodeHeads, wg)
719 }
720 }
721 // wait for all the goroutines to finish
722 wg.Wait()
723}
724
725// resolveCustomField resolves the @custom childField by making an external HTTP request and then
726// updates the fastJson tree with results of that HTTP request.

Callers 2

processCustomFieldsMethod · 0.95
resolveNestedFieldsMethod · 0.95

Calls 8

resolveCustomFieldMethod · 0.95
resolveNestedFieldsMethod · 0.95
WaitMethod · 0.80
SkipMethod · 0.65
IncludeMethod · 0.65
IsCustomHTTPMethod · 0.65
HasCustomHTTPChildMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected