Skip to content

Commit 0d1614a

Browse files
authored
Export isNetworkStatusInFlight (#12866)
1 parent b00f231 commit 0d1614a

File tree

14 files changed

+79
-34
lines changed

14 files changed

+79
-34
lines changed

.api-reports/api-report-core.api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { InMemoryCache } from '@apollo/client/cache';
5252
import { InMemoryCacheConfig } from '@apollo/client/cache';
5353
import type { InteropObservable } from 'rxjs';
5454
import type { IsAny } from '@apollo/client/utilities/internal';
55+
import { isNetworkRequestSettled } from '@apollo/client/utilities';
5556
import { isReference } from '@apollo/client/utilities';
5657
import { LinkError } from '@apollo/client/errors';
5758
import type { LocalState } from '@apollo/client/local-state';
@@ -529,8 +530,7 @@ export namespace InternalTypes {
529530
export type { NextFetchPolicyContext, QueryManager };
530531
}
531532

532-
// @public
533-
export function isNetworkRequestSettled(networkStatus?: NetworkStatus): boolean;
533+
export { isNetworkRequestSettled }
534534

535535
export { isReference }
536536

@@ -1133,8 +1133,8 @@ export type WatchQueryOptions<TVariables extends OperationVariables = OperationV
11331133
// Warnings were encountered during analysis:
11341134
//
11351135
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
1136-
// src/core/ObservableQuery.ts:360:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
1137-
// src/core/QueryManager.ts:175:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
1136+
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
1137+
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
11381138

11391139
// (No @packageDocumentation comment for this package)
11401140

.api-reports/api-report-utilities.api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { FieldNode } from 'graphql';
1313
import type { FieldPolicy } from '@apollo/client/cache';
1414
import type { FormattedExecutionResult } from 'graphql';
1515
import { getMainDefinition } from '@apollo/client/utilities/internal';
16+
import type { NetworkStatus } from '@apollo/client';
1617
import { Observable } from 'rxjs';
1718
import type { Primitive } from '@apollo/client/utilities/internal';
1819
import type { Reference as Reference_2 } from '@apollo/client/cache';
@@ -137,6 +138,12 @@ export function isFormattedExecutionResult(result?: object): result is Formatted
137138
// @public
138139
export function isMutationOperation(document: DocumentNode_2): boolean;
139140

141+
// @public
142+
export function isNetworkRequestInFlight(networkStatus?: NetworkStatus): boolean;
143+
144+
// @public
145+
export function isNetworkRequestSettled(networkStatus?: NetworkStatus): boolean;
146+
140147
// @public
141148
export function isQueryOperation(document: DocumentNode_2): boolean;
142149

.api-reports/api-report.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,8 +2713,8 @@ interface WriteContext extends ReadMergeModifyContext {
27132713
// src/cache/inmemory/types.ts:134:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
27142714
// src/core/ApolloClient.ts:159:5 - (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
27152715
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
2716-
// src/core/ObservableQuery.ts:360:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
2717-
// src/core/QueryManager.ts:175:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
2716+
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
2717+
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
27182718
// src/local-state/LocalState.ts:147:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
27192719
// src/local-state/LocalState.ts:200:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
27202720
// src/local-state/LocalState.ts:243:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts

.changeset/rude-pigs-own.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@apollo/client-codemod-migrate-3-to-4": patch
3+
"@apollo/client": patch
4+
---
5+
6+
Export `isNetworkStatusInFlight` from `@apollo/client/utilities`. Add `isNetworkStatusSettled` to `@apollo/client/utilities` and re-export it from `@apollo/client` with a deprecation.

.size-limits.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 43932,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38712,
4-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33629,
5-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27675
2+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 43875,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38673,
4+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33588,
5+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27661
66
}

scripts/codemods/ac3-to-ac4/src/renames.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,21 @@ export const renames: Array<IdentifierRename | ModuleRename> = [
710710
importType: "type",
711711
})
712712
),
713+
...[
714+
{ from: "isNetworkRequestInFlight" },
715+
{ from: "isNetworkRequestSettled" },
716+
].map(
717+
moveInto({
718+
from: {
719+
module: "@apollo/client/core/networkStatus",
720+
alternativeModules: ["@apollo/client/core", "@apollo/client"],
721+
},
722+
to: {
723+
module: "@apollo/client/utilities",
724+
},
725+
importType: "value",
726+
})
727+
),
713728
// no direct 1:1 drop-in replacement
714729
// {
715730
// from: { module: "@apollo/client/react/ssr", identifier: "renderToStringWithData" },

src/__tests__/__snapshots__/exports.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ Array [
395395
"getMainDefinition",
396396
"isFormattedExecutionResult",
397397
"isMutationOperation",
398+
"isNetworkRequestInFlight",
399+
"isNetworkRequestSettled",
398400
"isQueryOperation",
399401
"isReference",
400402
"isSubscriptionOperation",

src/core/ObservableQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { Cache, MissingFieldError } from "@apollo/client/cache";
1414
import type { MissingTree } from "@apollo/client/cache";
1515
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
1616
import type { DeepPartial } from "@apollo/client/utilities";
17+
import { isNetworkRequestInFlight } from "@apollo/client/utilities";
1718
import { __DEV__ } from "@apollo/client/utilities/environment";
1819
import {
1920
compact,
@@ -28,7 +29,7 @@ import {
2829
import { invariant } from "@apollo/client/utilities/invariant";
2930

3031
import type { ApolloClient } from "./ApolloClient.js";
31-
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
32+
import { NetworkStatus } from "./networkStatus.js";
3233
import type { QueryManager } from "./QueryManager.js";
3334
import type {
3435
DataState,

src/core/QueryManager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ import type { LocalState } from "@apollo/client/local-state";
4040
import type { MaybeMasked } from "@apollo/client/masking";
4141
import { maskFragment, maskOperation } from "@apollo/client/masking";
4242
import type { DeepPartial } from "@apollo/client/utilities";
43-
import { cacheSizes, DocumentTransform, print } from "@apollo/client/utilities";
43+
import {
44+
cacheSizes,
45+
DocumentTransform,
46+
isNetworkRequestInFlight,
47+
print,
48+
} from "@apollo/client/utilities";
4449
import { __DEV__ } from "@apollo/client/utilities/environment";
4550
import {
4651
AutoCleanedWeakCache,
@@ -66,7 +71,7 @@ import {
6671
import { defaultCacheSizes } from "../utilities/caching/sizes.js";
6772

6873
import type { ApolloClient } from "./ApolloClient.js";
69-
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
74+
import { NetworkStatus } from "./networkStatus.js";
7075
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
7176
import { CacheWriteBehavior, QueryInfo } from "./QueryInfo.js";
7277
import type {

src/core/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type {
2727
UpdateQueryOptions,
2828
WatchQueryFetchPolicy,
2929
} from "./watchQueryOptions.js";
30-
export { isNetworkRequestSettled, NetworkStatus } from "./networkStatus.js";
30+
export { NetworkStatus } from "./networkStatus.js";
3131
export type {
3232
DataState,
3333
DataValue,
@@ -151,6 +151,8 @@ export type {
151151
} from "@apollo/client/utilities";
152152
export {
153153
DocumentTransform,
154+
/** @deprecated Please import `isNetworkRequestSettled` from `@apollo/client/utilities`. */
155+
isNetworkRequestSettled,
154156
isReference,
155157
Observable,
156158
} from "@apollo/client/utilities";

0 commit comments

Comments
 (0)