diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index 03674d849aa..3d68ac1a657 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -35,6 +35,7 @@ import type { QueryInfo } from "./QueryInfo.js"; import type { MissingFieldError } from "../cache/index.js"; import type { MissingTree } from "../cache/core/types/common.js"; import { equalByQuery } from "./equalByQuery.js"; +import type { TODO } from "../utilities/types/TODO.js"; const { assign, hasOwnProperty } = Object; @@ -408,7 +409,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`, } this.queryInfo.resetLastWrite(); - return this.reobserve(reobserveOptions, NetworkStatus.refetch); + return this.reobserve(reobserveOptions, NetworkStatus.refetch) as TODO; } public fetchMore< @@ -588,7 +589,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`, public setOptions( newOptions: Partial> ): Promise> { - return this.reobserve(newOptions); + return this.reobserve(newOptions) as TODO; } public silentSetOptions( @@ -928,9 +929,7 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`, newOptions?: Partial>, newNetworkStatus?: NetworkStatus ) { - return this.reobserveAsConcast(newOptions, newNetworkStatus).promise.then( - ensureResult - ); + return this.reobserveAsConcast(newOptions, newNetworkStatus).promise; } public resubscribeAfterError( @@ -1096,13 +1095,3 @@ function skipCacheDataFor( fetchPolicy === "standby" ); } - -export function ensureResult( - value: ApolloQueryResult | undefined -): ApolloQueryResult { - invariant( - value, - "A Concast finished without a result. This in an Apollo Client bug, please file a bug report." - ); - return value; -} diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts index fe7a17ca479..6d2bb778591 100644 --- a/src/core/QueryManager.ts +++ b/src/core/QueryManager.ts @@ -51,11 +51,7 @@ import type { ErrorPolicy, MutationFetchPolicy, } from "./watchQueryOptions.js"; -import { - ObservableQuery, - ensureResult, - logMissingFieldErrors, -} from "./ObservableQuery.js"; +import { ObservableQuery, logMissingFieldErrors } from "./ObservableQuery.js"; import { NetworkStatus, isNetworkRequestInFlight } from "./networkStatus.js"; import type { ApolloQueryResult, @@ -78,6 +74,7 @@ import { import type { ApolloErrorOptions } from "../errors/index.js"; import { PROTOCOL_ERRORS_SYMBOL } from "../errors/index.js"; import { print } from "../utilities/index.js"; +import type { TODO } from "../utilities/types/TODO.js"; const { hasOwnProperty } = Object.prototype; @@ -620,11 +617,8 @@ export class QueryManager { options: WatchQueryOptions, networkStatus?: NetworkStatus ): Promise> { - return this.fetchConcastWithInfo( - queryId, - options, - networkStatus - ).concast.promise.then(ensureResult); + return this.fetchConcastWithInfo(queryId, options, networkStatus).concast + .promise as TODO; } public getQueryStore() { diff --git a/src/react/cache/QueryReference.ts b/src/react/cache/QueryReference.ts index 7a03ea10d37..9a8ed93ca77 100644 --- a/src/react/cache/QueryReference.ts +++ b/src/react/cache/QueryReference.ts @@ -14,6 +14,7 @@ import { } from "../../utilities/index.js"; import type { CacheKey } from "./types.js"; import type { useBackgroundQuery, useReadQuery } from "../hooks/index.js"; +import type { TODO } from "../../utilities/types/TODO.js"; type Listener = (promise: Promise>) => void; @@ -174,7 +175,7 @@ export class InternalQueryReference { currentFetchPolicy === "standby" && currentFetchPolicy !== watchQueryOptions.fetchPolicy ) { - this.initiateFetch(this.observable.reobserve(watchQueryOptions)); + this.initiateFetch(this.observable.reobserve(watchQueryOptions) as TODO); } else { this.observable.silentSetOptions(watchQueryOptions); diff --git a/src/utilities/types/TODO.ts b/src/utilities/types/TODO.ts new file mode 100644 index 00000000000..a5d637cc22c --- /dev/null +++ b/src/utilities/types/TODO.ts @@ -0,0 +1,2 @@ +/** @internal */ +export type TODO = any;