diff --git a/packages/vue-apollo-composable/src/useQuery.ts b/packages/vue-apollo-composable/src/useQuery.ts index 67da52c..da28335 100644 --- a/packages/vue-apollo-composable/src/useQuery.ts +++ b/packages/vue-apollo-composable/src/useQuery.ts @@ -250,6 +250,10 @@ export function useQueryImpl< } function onNextResult (queryResult: ApolloQueryResult) { + // Remove any previous error that may still be present from the last fetch (so result handlers + // don't receive old errors that may not even be applicable anymore). + error.value = null + processNextResult(queryResult) // Result errors diff --git a/packages/vue-apollo-composable/src/util/ExtractSingleKey.ts b/packages/vue-apollo-composable/src/util/ExtractSingleKey.ts index 2f20fb8..ff98ca8 100644 --- a/packages/vue-apollo-composable/src/util/ExtractSingleKey.ts +++ b/packages/vue-apollo-composable/src/util/ExtractSingleKey.ts @@ -6,4 +6,4 @@ export type IsUnion = U extends any ? ([T] extends [U] ? false : true) /** * Extracts an inner type if T has a single key K, otherwise it returns T. */ -export type ExtractSingleKey = IsUnion extends true ? T : T[K] +export type ExtractSingleKey> = IsUnion extends true ? T : T[KWithoutTypename] diff --git a/packages/vue-apollo-composable/tests/fixtures/graphql-example-types.ts b/packages/vue-apollo-composable/tests/fixtures/graphql-example-types.ts index e20b7b6..5a7ae69 100644 --- a/packages/vue-apollo-composable/tests/fixtures/graphql-example-types.ts +++ b/packages/vue-apollo-composable/tests/fixtures/graphql-example-types.ts @@ -71,12 +71,14 @@ export interface ExampleUpdatedSubscriptionVariables { } export interface SingleKeyExampleQuery { + __typename?: 'Root' example?: { __typename?: 'Example' } } export interface MultiKeyExampleQuery { + __typename?: 'Root' example?: { __typename?: 'Example' }