MCPcopy Create free account
hub / github.com/cli/cli / object

Method object

script/ghmock/trim.go:62–90  ·  view source on GitHub ↗
(obj map[string]any, sel ast.SelectionSet)

Source from the content-addressed store, hash-verified

60}
61
62func (t *trimmer) object(obj map[string]any, sel ast.SelectionSet) map[string]any {
63 typename, _ := obj["__typename"].(string)
64 var keys []string
65 groups := map[string][]*ast.Field{}
66 t.collect(sel, typename, map[string]bool{}, &keys, groups)
67 if typename == "" {
68 for _, key := range keys {
69 if groups[key][0].Name == "__typename" {
70 typename, _ = obj[key].(string)
71 if typename != "" {
72 break
73 }
74 }
75 }
76 if typename != "" {
77 keys = nil
78 groups = map[string][]*ast.Field{}
79 t.collect(sel, typename, map[string]bool{}, &keys, groups)
80 }
81 }
82
83 out := make(map[string]any, len(keys))
84 for _, key := range keys {
85 if v, ok := obj[key]; ok {
86 out[key] = t.value(v, mergeSelections(groups[key]))
87 }
88 }
89 return out
90}
91
92func (t *trimmer) value(v any, sel ast.SelectionSet) any {
93 if len(sel) == 0 {

Callers 6

trimGraphQLFunction · 0.95
valueMethod · 0.95
sandbox.tsFile · 0.80
calls.tsFile · 0.80
domain.tsFile · 0.80
evidence.tsFile · 0.80

Calls 3

collectMethod · 0.95
valueMethod · 0.95
mergeSelectionsFunction · 0.85

Tested by

no test coverage detected