Repository: tannerlinsley/react-query (ts)

Issue:
[Typescript] Support for default query function
**Describe the bug**
Providing a default query function is not supported in Typescript. The option `queryFn` (as described [here](https://react-query.tanstack.com/docs/guides/default-query-function)) does not exists in the type `ReactQueryProviderConfig`.

**To Reproduce**
In a Typescript setting:
```typescript
<ReactQueryConfigProvider
  config={{
    queries: {
      queryFn: defaultQueryFn,
    },
  }}
>
```

**Additional context**
React-query version: 2.4.15


Pull request description:
fix(types): add queryFn to ReactQueryProviderConfig
Fix #743

Patch:
diff --git a/src/core/queryCache.js b/src/core/queryCache.js
index 4b34fc0f2..813b7ef47 100644
--- a/src/core/queryCache.js
+++ b/src/core/queryCache.js
@@ -208,6 +208,9 @@ export function makeQueryCache({ frozen = isServer, defaultConfig } = {}) {
 
     let [queryKey, config, { force, throwOnError } = {}] = getQueryArgs(args)
 
+    // https://github.com/tannerlinsley/react-query/issues/652
+    config = { retry: false, ...config }
+
     try {
       const query = queryCache.buildQuery(queryKey, config)
       if (force || query.state.isStale) {
diff --git a/types/index.d.ts b/types/index.d.ts
index e1b3babbc..0a3f15bff 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -615,7 +615,9 @@ export interface QueryCache {
     queryKeyOrPredicateFn: QueryKeyOrPredicateFn,
     { exact }?: { exact?: boolean }
   ): void
-  getQuery(queryKeyOrPredicateFn: QueryKeyOrPredicateFn): CachedQuery<unknown> | undefined
+  getQuery(
+    queryKeyOrPredicateFn: QueryKeyOrPredicateFn
+  ): CachedQuery<unknown> | undefined
   getQueries(
     queryKeyOrPredicateFn: QueryKeyOrPredicateFn,
     { exact }?: { exact?: boolean }
@@ -671,6 +673,7 @@ export interface ReactQueryProviderConfig<TError = Error> {
     /** Defaults to the value of `suspense` if not defined otherwise */
     useErrorBoundary?: boolean
     refetchOnWindowFocus?: boolean
+    queryFn?: QueryFunction<unknown, AnyQueryKey>
     queryKeySerializerFn?: (
       queryKey: QueryKeyPart[] | string | false | undefined
     ) => [string, QueryKeyPart[]] | []


Test patch:
diff --git a/src/core/tests/queryCache.test.js b/src/core/tests/queryCache.test.js
index 9868fef23..74feba9ed 100644
--- a/src/core/tests/queryCache.test.js
+++ b/src/core/tests/queryCache.test.js
@@ -23,6 +23,20 @@ describe('queryCache', () => {
     ).not.toThrow()
   })
 
+  // https://github.com/tannerlinsley/react-query/issues/652
+  test('prefetchQuery should not retry by default', async () => {
+    await expect(
+      queryCache.prefetchQuery(
+        'key',
+        async () => {
+          throw new Error('error')
+        },
+        {},
+        { throwOnError: true }
+      )
+    ).rejects.toEqual(new Error('error'))
+  })
+
   test('prefetchQuery returns the cached data on cache hits', async () => {
     const fetchFn = () => Promise.resolve('data')
     const first = await queryCache.prefetchQuery('key', fetchFn)