functionCall is executed for every command that the exec handler processes
(ctx context.Context, st *ShellState, name string, args []string)
| 433 | |
| 434 | // functionCall is executed for every command that the exec handler processes |
| 435 | func (h *shellCallHandler) functionCall(ctx context.Context, st *ShellState, name string, args []string) (*ShellState, error) { |
| 436 | def := h.GetDef(st) |
| 437 | call := st.Function() |
| 438 | |
| 439 | fn, err := call.GetNextDef(def, name) |
| 440 | // If the current value is typed as an interface, the next command may be |
| 441 | // provided by its concrete implementation rather than the interface itself. |
| 442 | // Ask GraphQL for the concrete __typename and continue through an inline |
| 443 | // fragment so we don't have to invent some sort of inline fragment shell |
| 444 | // syntax. |
| 445 | if err != nil && def.GetInterface(call.ReturnObject) != nil { |
| 446 | st, err = h.resolveConcreteReturnObject(ctx, st) |
| 447 | if err == nil { |
| 448 | call = st.Function() |
| 449 | fn, err = call.GetNextDef(def, name) |
| 450 | } |
| 451 | } |
| 452 | if err != nil { |
| 453 | return st, err |
| 454 | } |
| 455 | |
| 456 | argValues, err := h.parseArgumentValues(ctx, def, fn, args) |
| 457 | if err != nil { |
| 458 | return st, fmt.Errorf("function %q: %w", fn.CmdName(), err) |
| 459 | } |
| 460 | |
| 461 | newSt := st.WithCall(fn, argValues) |
| 462 | |
| 463 | return &newSt, nil |
| 464 | } |
| 465 | |
| 466 | func (h *shellCallHandler) resolveConcreteReturnObject(ctx context.Context, st *ShellState) (*ShellState, error) { |
| 467 | call := st.Function() |
no test coverage detected