* Checks whether a query should fetch for a `refetchOnMount`, `refetchOnWindowFocus`, or * `refetchOnReconnect` option. * @param query - The query to check. * @param options - The observer options. * @param field - The value of the option to check. * @returns `true` if the query is enabled, not
(
query: Query<any, any, any, any>,
options: QueryObserverOptions<any, any, any, any, any>,
field: (typeof options)['refetchOnMount'] &
(typeof options)['refetchOnWindowFocus'] &
(typeof options)['refetchOnReconnect'],
)
| 920 | * `false` and the query is stale. |
| 921 | */ |
| 922 | function shouldFetchOn( |
| 923 | query: Query<any, any, any, any>, |
| 924 | options: QueryObserverOptions<any, any, any, any, any>, |
| 925 | field: (typeof options)['refetchOnMount'] & |
| 926 | (typeof options)['refetchOnWindowFocus'] & |
| 927 | (typeof options)['refetchOnReconnect'], |
| 928 | ) { |
| 929 | if ( |
| 930 | resolveQueryValue(options.enabled, query) !== false && |
| 931 | resolveQueryValue(options.staleTime, query) !== 'static' |
| 932 | ) { |
| 933 | const value = resolveQueryValue(field, query) |
| 934 | |
| 935 | return value === 'always' || (value !== false && isStale(query, options)) |
| 936 | } |
| 937 | return false |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * Checks whether a query should fetch after the observer's options change. |
no test coverage detected