| 31 | } |
| 32 | |
| 33 | export function resolve(value: any, config: Config = {}): any { |
| 34 | if (value == null || typeof value !== 'object') return value; |
| 35 | |
| 36 | if (Array.isArray(value)) return value.map((item) => resolve(item, config)); |
| 37 | |
| 38 | if (isAst(value) && value?.resolve instanceof Function) |
| 39 | return value.resolve(config); |
| 40 | |
| 41 | if (Object.getPrototypeOf(value) !== Object.prototype) return value; |
| 42 | |
| 43 | const output: Record<string, Scalar> = {}; |
| 44 | for (const [k, v] of Object.entries(value)) output[k] = resolve(v, config); |
| 45 | return output; |
| 46 | } |