Repository: tannerlinsley/react-query (ts)

Issue:
queries retrying even though option is set to false
**Describe the bug**

While upgrading to v2 I noticed that some tests broke because `useQuery` does no longer use the config from the provider when you prefetch.

**To Reproduce**

Steps to reproduce the behavior:

1. Go to https://codesandbox.io/s/sweet-resonance-zu0em?file=/src/App.js
2. Check the console
4. See multiple logs from react-query trying to retry even though the option is set to `false`

**Expected behavior**

Queries does not retry if option is set to `false`

**Screenshots**
N/A

**Desktop (please complete the following information):**
N/A

**Smartphone (please complete the following information):**
N/A

**Additional context**
N/A


Pull request description:
fix:(prefetchQuery): override default retry behaviour to false
Fix #652 

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) {


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)