Skip to content

Commit 714b587

Browse files
fix: call unref on query variables (#601)
1 parent ec1515a commit 714b587

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime/composables.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { print } from 'graphql'
33
import type { ApolloClient, OperationVariables, QueryOptions, DefaultContext } from '@apollo/client'
44
import type { AsyncData, AsyncDataOptions, NuxtError, NuxtApp } from 'nuxt/app'
55
import type { RestartableClient } from './ws'
6-
import { ref, isRef, reactive, useCookie, useNuxtApp, useAsyncData } from '#imports'
6+
import { ref, unref, isRef, reactive, useCookie, useNuxtApp, useAsyncData } from '#imports'
77
import { NuxtApollo } from '#apollo'
88
import type { ApolloClientKeys } from '#apollo'
99

@@ -163,11 +163,11 @@ const prep = <T> (...args: any[]) => {
163163
options.watch.push(variables)
164164
}
165165

166-
const key: string = args?.[0]?.key || hash({ query: print(query), variables, clientId })
166+
const key: string = args?.[0]?.key || hash({ query: print(query), unref(variables), clientId })
167167

168168
const fn = () => clients![clientId!]?.query<T>({
169169
query,
170-
variables: variables || undefined,
170+
variables: unref(variables) || undefined,
171171
...(cache && { fetchPolicy: 'cache-first' }),
172172
context
173173
}).then(r => r.data)

0 commit comments

Comments
 (0)