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

Method rewriteAndExecute

graphql/resolve/resolver.go:703–728  ·  view source on GitHub ↗
(ctx context.Context, field schema.Field)

Source from the content-addressed store, hash-verified

701}
702
703func (hr *httpResolver) rewriteAndExecute(ctx context.Context, field schema.Field) *Resolved {
704 hrc, err := field.CustomHTTPConfig()
705 if err != nil {
706 return EmptyResult(field, err)
707 }
708
709 // If this is a lambda field, it will always have a body template.
710 // Just convert that into a lambda template.
711 if field.HasLambdaDirective() {
712 hrc.Template = schema.GetBodyForLambda(ctx, field, nil, hrc.Template)
713 }
714
715 fieldData, errs, hardErrs := hrc.MakeAndDecodeHTTPRequest(hr.Client, hrc.URL, hrc.Template,
716 field)
717 if hardErrs != nil {
718 // Not using EmptyResult() here as we don't want to wrap the errors returned from remote
719 // endpoints
720 return &Resolved{
721 Data: field.NullResponse(),
722 Field: field,
723 Err: hardErrs,
724 }
725 }
726
727 return DataResult(field, map[string]interface{}{field.Name(): fieldData}, errs)
728}
729
730func (h *httpQueryResolver) Resolve(ctx context.Context, query schema.Query) *Resolved {
731 return (*httpResolver)(h).Resolve(ctx, query)

Callers 1

ResolveMethod · 0.95

Calls 8

GetBodyForLambdaFunction · 0.92
EmptyResultFunction · 0.85
DataResultFunction · 0.85
CustomHTTPConfigMethod · 0.65
HasLambdaDirectiveMethod · 0.65
NullResponseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected