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

Method expandFragments

dql/parser.go:266–291  ·  view source on GitHub ↗
(fmap fragmentMap)

Source from the content-addressed store, hash-verified

264}
265
266func (gq *GraphQuery) expandFragments(fmap fragmentMap) error {
267 // We have to make a copy of children to preserve order and replace
268 // fragment references with fragment content. The copy is newChildren.
269 var newChildren []*GraphQuery
270 // Expand non-fragments. Do not append to gq.Children.
271 for _, child := range gq.Children {
272 if child.isFragment() {
273 fname := child.fragment // Name of fragment being referenced.
274 fchild := fmap[fname]
275 if fchild == nil {
276 return errors.Errorf("Missing fragment: %s", fname)
277 }
278 if err := fchild.expand(fmap); err != nil {
279 return err
280 }
281 newChildren = append(newChildren, fchild.Gq.Children...)
282 } else {
283 if err := child.expandFragments(fmap); err != nil {
284 return err
285 }
286 newChildren = append(newChildren, child)
287 }
288 }
289 gq.Children = newChildren
290 return nil
291}
292
293func convertToVarMap(variables map[string]string) (vm varMap) {
294 vm = make(map[string]varInfo)

Callers 2

ParseWithNeedVarsFunction · 0.95
expandMethod · 0.80

Calls 3

isFragmentMethod · 0.80
expandMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected