(dirs ast.DirectiveList, variables map[string]any)
| 263 | } |
| 264 | |
| 265 | func 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 | |
| 294 | func (w *gqlWalker) isA(concrete *ast.Definition, name string) bool { |
| 295 | return isA(w.schema, concrete, name) |
no test coverage detected