Skip to content

Commit

Permalink
fix: TAsyncQuery type and context value as 4th argument (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdEijnden committed Nov 23, 2023
1 parent 8f3298d commit 67623b0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import NuxtApollo from '#build/apollo'
type TQuery<T> = QueryOptions<OperationVariables, T>['query']
type TVariables<T> = QueryOptions<OperationVariables, T>['variables']
type TAsyncQuery<T> = {
cache?: boolean,
context?: DefaultContext,
clientId?: string,
key?: string,
query: TQuery<T>,
variables?: TVariables<T>,
key?: string,
cache?: boolean
clientId?: string
}

export function useAsyncQuery <T> (opts: TAsyncQuery<T>): AsyncData<T, Error>
Expand All @@ -40,8 +41,8 @@ const prep = (...args: any) => {
const query = args?.[0]?.query || args?.[0]
const cache = args?.[0]?.cache ?? true
const variables = args?.[0]?.variables || (typeof args?.[1] !== 'string' && args?.[1]) || undefined
const context = args?.[0]?.context
let clientId = args?.[0]?.clientId || (typeof args?.[1] === 'string' && args?.[1]) || undefined
const context = args?.[0]?.context || (typeof args?.[1] === 'string' && args?.[3]) || undefined
let clientId = args?.[0]?.clientId || (typeof args?.[1] === 'string' && args?.[2]) || undefined

if (!clientId || !clients?.[clientId]) {
clientId = clients?.default ? 'default' : Object.keys(clients!)[0]
Expand Down

0 comments on commit 67623b0

Please sign in to comment.