Skip to content

Commit

Permalink
remove ensureResult for this PR, add TODO type
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Sep 14, 2023
1 parent a101977 commit c83b042
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
18 changes: 4 additions & 14 deletions src/core/ObservableQuery.ts
Expand Up @@ -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;

Expand Down Expand Up @@ -927,10 +928,9 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
public reobserve(
newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,
newNetworkStatus?: NetworkStatus
) {
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise.then(
ensureResult
);
): Promise<ApolloQueryResult<TData>> {
return this.reobserveAsConcast(newOptions, newNetworkStatus)
.promise as TODO;
}

public resubscribeAfterError(
Expand Down Expand Up @@ -1096,13 +1096,3 @@ function skipCacheDataFor(
fetchPolicy === "standby"
);
}

export function ensureResult<TData = any>(
value: ApolloQueryResult<TData> | undefined
): ApolloQueryResult<TData> {
invariant(
value,
"A Concast finished without a result. This in an Apollo Client bug, please file a bug report."
);
return value;
}
14 changes: 4 additions & 10 deletions src/core/QueryManager.ts
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -620,11 +617,8 @@ export class QueryManager<TStore> {
options: WatchQueryOptions<TVars, TData>,
networkStatus?: NetworkStatus
): Promise<ApolloQueryResult<TData>> {
return this.fetchConcastWithInfo(
queryId,
options,
networkStatus
).concast.promise.then(ensureResult);
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast
.promise as TODO;
}

public getQueryStore() {
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/types/TODO.ts
@@ -0,0 +1,2 @@
/** @internal */
export type TODO = any;

0 comments on commit c83b042

Please sign in to comment.