( obj: MaybeRefDeep<T>, unrefGetters = false, )
| 82 | * be passed straight through to `@tanstack/query-core`. |
| 83 | */ |
| 84 | export function cloneDeepUnref<T>( |
| 85 | obj: MaybeRefDeep<T>, |
| 86 | unrefGetters = false, |
| 87 | ): T { |
| 88 | return cloneDeep(obj, (val, key, level) => { |
| 89 | // Check if we're at the top level and the key is 'queryKey' |
| 90 | // |
| 91 | // If so, take the recursive descent where we resolve |
| 92 | // getters to values as well as refs. |
| 93 | if (level === 1 && key === 'queryKey') { |
| 94 | return cloneDeepUnref(val, true) |
| 95 | } |
| 96 | |
| 97 | // Resolve getters to values if specified. |
| 98 | if (unrefGetters && isFunction(val)) { |
| 99 | // Cast due to older TS versions not allowing calling |
| 100 | // on certain intersection types. |
| 101 | return cloneDeepUnref((val as Function)(), unrefGetters) |
| 102 | } |
| 103 | |
| 104 | // Unref refs and continue to recurse into the value. |
| 105 | if (isRef(val)) { |
| 106 | return cloneDeepUnref(unref(val), unrefGetters) |
| 107 | } |
| 108 | |
| 109 | return undefined |
| 110 | }) |
| 111 | } |
| 112 | |
| 113 | // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types |
| 114 | function isPlainObject(value: unknown): value is Object { |
no test coverage detected