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

Method collectFields

script/ghmock/graphqlcheck.go:231–247  ·  view source on GitHub ↗

collectFields lists the fields a selection set asks for on an object of type concrete. concrete is nil when the object's type isn't known, which happens for interfaces and unions when the response has no __typename.

(sel ast.SelectionSet, concrete *ast.Definition, required, checked bool, out *[]selected)

Source from the content-addressed store, hash-verified

229// concrete. concrete is nil when the object's type isn't known, which happens
230// for interfaces and unions when the response has no __typename.
231func (w *gqlWalker) collectFields(sel ast.SelectionSet, concrete *ast.Definition, required, checked bool, out *[]selected) {
232 for _, s := range sel {
233 switch s := s.(type) {
234 case *ast.Field:
235 included, known := directiveCondition(s.Directives, w.variables)
236 if included {
237 *out = append(*out, selected{field: s, required: required && known, checked: checked})
238 }
239 case *ast.InlineFragment:
240 w.collectFragment(s.TypeCondition, s.Directives, s.SelectionSet, concrete, required, checked, out)
241 case *ast.FragmentSpread:
242 if s.Definition != nil {
243 w.collectFragment(s.Definition.TypeCondition, s.Directives, s.Definition.SelectionSet, concrete, required, checked, out)
244 }
245 }
246 }
247}
248
249func (w *gqlWalker) collectFragment(cond string, dirs ast.DirectiveList, sel ast.SelectionSet, concrete *ast.Definition, required, checked bool, out *[]selected) {
250 included, known := directiveCondition(dirs, w.variables)

Callers 2

collectFragmentMethod · 0.95
checkObjectMethod · 0.95

Calls 2

collectFragmentMethod · 0.95
directiveConditionFunction · 0.85

Tested by

no test coverage detected