StateResult resolves a state into a value, more commonly by making an API request.
(ctx context.Context, st *ShellState)
| 912 | |
| 913 | // StateResult resolves a state into a value, more commonly by making an API request. |
| 914 | func (h *shellCallHandler) StateResult(ctx context.Context, st *ShellState) (*Result, error) { |
| 915 | if st == nil { |
| 916 | return nil, nil |
| 917 | } |
| 918 | |
| 919 | def := h.GetDef(st) |
| 920 | var err error |
| 921 | |
| 922 | // Example: `build` (i.e., omitted constructor) |
| 923 | // Call the module's named constructor on Query. |
| 924 | if def.HasModule() && st.IsEmpty() { |
| 925 | if fn := def.ModuleConstructor(); fn != nil { |
| 926 | newSt := st.WithCall(fn, nil) |
| 927 | st = &newSt |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | fn, err := st.Function().GetDef(def) |
| 932 | if err != nil { |
| 933 | return nil, err |
| 934 | } |
| 935 | |
| 936 | r := &Result{typeDef: fn.ReturnType} |
| 937 | q := handleObjectLeaf(st.QueryBuilder(h.dag), fn.ReturnType) |
| 938 | err = makeRequest(ctx, q, &r.Value) |
| 939 | |
| 940 | return r, err |
| 941 | } |
| 942 | |
| 943 | func (h *shellCallHandler) getOrInitDef(ref string, fn func() (*moduleDef, error)) (*moduleDef, error) { |
| 944 | // Fast path |
no test coverage detected