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

Function directiveCondition

script/ghmock/graphqlcheck.go:265–292  ·  view source on GitHub ↗
(dirs ast.DirectiveList, variables map[string]any)

Source from the content-addressed store, hash-verified

263}
264
265func directiveCondition(dirs ast.DirectiveList, variables map[string]any) (included, known bool) {
266 known = true
267 for _, name := range []string{"include", "skip"} {
268 d := dirs.ForName(name)
269 if d == nil {
270 continue
271 }
272 arg := d.Arguments.ForName("if")
273 if arg == nil {
274 known = false
275 continue
276 }
277 if variables == nil && arg.Value.Kind == ast.Variable {
278 known = false
279 continue
280 }
281 value, err := arg.Value.Value(variables)
282 condition, ok := value.(bool)
283 if err != nil || !ok {
284 known = false
285 continue
286 }
287 if name == "skip" && condition || name == "include" && !condition {
288 return false, true
289 }
290 }
291 return true, known
292}
293
294func (w *gqlWalker) isA(concrete *ast.Definition, name string) bool {
295 return isA(w.schema, concrete, name)

Callers 2

collectFieldsMethod · 0.85
collectFragmentMethod · 0.85

Calls 1

ValueMethod · 0.80

Tested by

no test coverage detected