Skip to content

Commit

Permalink
fix: call unref on query variables (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphazardous authored Mar 15, 2024
1 parent ec1515a commit 714b587
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { print } from 'graphql'
import type { ApolloClient, OperationVariables, QueryOptions, DefaultContext } from '@apollo/client'
import type { AsyncData, AsyncDataOptions, NuxtError, NuxtApp } from 'nuxt/app'
import type { RestartableClient } from './ws'
import { ref, isRef, reactive, useCookie, useNuxtApp, useAsyncData } from '#imports'
import { ref, unref, isRef, reactive, useCookie, useNuxtApp, useAsyncData } from '#imports'
import { NuxtApollo } from '#apollo'
import type { ApolloClientKeys } from '#apollo'

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

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

const fn = () => clients![clientId!]?.query<T>({
query,
variables: variables || undefined,
variables: unref(variables) || undefined,
...(cache && { fetchPolicy: 'cache-first' }),
context
}).then(r => r.data)
Expand Down

0 comments on commit 714b587

Please sign in to comment.