From 575c1d99d682eff476fd57b94e5911f632328b40 Mon Sep 17 00:00:00 2001 From: Conrawl Rogers Date: Fri, 1 Mar 2024 10:17:21 -0400 Subject: [PATCH] fix: ensure `useAsyncQuery` aheres to it's apollo client's `fetchPolicy`, allowing `cache-first` override via the `cache` flag. --- src/runtime/composables.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/composables.ts b/src/runtime/composables.ts index 7ac41123..4f432b89 100644 --- a/src/runtime/composables.ts +++ b/src/runtime/composables.ts @@ -69,7 +69,7 @@ const prep = (...args: any[]) => { let query: TQuery let variables: TVariables - let cache: boolean = true + let cache: boolean let clientId: ApolloClientKeys | undefined let context: DefaultContext @@ -79,7 +79,7 @@ const prep = (...args: any[]) => { query = args?.[0]?.query variables = args?.[0]?.variables - cache = args?.[0]?.cache ?? true + cache = args?.[0]?.cache context = args?.[0]?.context clientId = args?.[0]?.clientId @@ -118,7 +118,7 @@ const prep = (...args: any[]) => { const fn = () => clients![clientId!]?.query({ query, variables: variables || undefined, - fetchPolicy: cache ? 'cache-first' : 'no-cache', + ...(cache && { fetchPolicy: 'cache-first' }), context }).then(r => r.data)