MCPcopy
hub / github.com/dosco/graphjin / execRemoteJoin

Method execRemoteJoin

core/remote_join.go:20–55  ·  view source on GitHub ↗

execRemoteJoin fetches remote data for the marked insertion points

(c context.Context)

Source from the content-addressed store, hash-verified

18
19// execRemoteJoin fetches remote data for the marked insertion points
20func (s *gstate) execRemoteJoin(c context.Context) (err error) {
21 // fetch the field name used within the db response json
22 // that are used to mark insertion points and the mapping between
23 // those field names and their select objects
24 fids, sfmap, err := s.parentFieldIds()
25 if err != nil {
26 return
27 }
28
29 // fetch the field values of the marked insertion points
30 // these values contain the id to be used with fetching remote data
31 from := jsn.Get(s.data, fids)
32 if len(from) == 0 {
33 err = errors.New("something wrong no remote ids found in db response")
34 return
35 }
36
37 to, extra, err := s.resolveRemotes(c, from, sfmap, s.requestedRootCursorFields())
38 if err != nil {
39 return
40 }
41
42 var ob bytes.Buffer
43 if err = jsn.Replace(&ob, s.data, from, to); err != nil {
44 return
45 }
46 s.data = ob.Bytes()
47 if len(extra) != 0 {
48 if s.data, err = mergeRemoteRootFields(s.data, extra); err != nil {
49 return
50 }
51 s.dhash = sha256.Sum256(s.data)
52 s.data, err = encryptValues(s.data, s.gj.printFormat, decPrefix, s.dhash[:], s.gj.encryptionKey)
53 }
54 return
55}
56
57// resolveRemotes fetches remote data for the marked insertion points
58func (s *gstate) resolveRemotes(

Callers 3

runForRefreshMethod · 0.95

Calls 6

parentFieldIdsMethod · 0.95
resolveRemotesMethod · 0.95
mergeRemoteRootFieldsFunction · 0.85
encryptValuesFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected