Method
value
(v any, sel ast.SelectionSet)
Source from the content-addressed store, hash-verified
| 90 | } |
| 91 | |
| 92 | func (t *trimmer) value(v any, sel ast.SelectionSet) any { |
| 93 | if len(sel) == 0 { |
| 94 | return v |
| 95 | } |
| 96 | switch v := v.(type) { |
| 97 | case map[string]any: |
| 98 | return t.object(v, sel) |
| 99 | case []any: |
| 100 | out := make([]any, len(v)) |
| 101 | for i, item := range v { |
| 102 | out[i] = t.value(item, sel) |
| 103 | } |
| 104 | return out |
| 105 | } |
| 106 | return v |
| 107 | } |
| 108 | |
| 109 | // collect lists the response keys a selection asks for on an object whose |
| 110 | // __typename is typename, merging the selections of fields that share a key. |
Tested by
no test coverage detected