diff --git a/src/cache/core/cache.ts b/src/cache/core/cache.ts index 1941c204de0..30069aa89be 100644 --- a/src/cache/core/cache.ts +++ b/src/cache/core/cache.ts @@ -1,13 +1,14 @@ -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import { wrap } from 'optimism'; -import { +import type { StoreObject, - Reference, + Reference} from '../../utilities'; +import { getFragmentQueryDocument, } from '../../utilities'; -import { DataProxy } from './types/DataProxy'; -import { Cache } from './types/Cache'; +import type { DataProxy } from './types/DataProxy'; +import type { Cache } from './types/Cache'; export type Transaction = (c: ApolloCache) => void; diff --git a/src/cache/core/types/Cache.ts b/src/cache/core/types/Cache.ts index 4086d34a45e..cb89169930b 100644 --- a/src/cache/core/types/Cache.ts +++ b/src/cache/core/types/Cache.ts @@ -1,6 +1,6 @@ import { DataProxy } from './DataProxy'; -import { Modifier, Modifiers } from './common'; -import { ApolloCache } from '../cache'; +import type { Modifier, Modifiers } from './common'; +import type { ApolloCache } from '../cache'; export namespace Cache { export type WatchCallback = ( diff --git a/src/cache/core/types/DataProxy.ts b/src/cache/core/types/DataProxy.ts index 097c3a4e04f..5d9e0fef1c5 100644 --- a/src/cache/core/types/DataProxy.ts +++ b/src/cache/core/types/DataProxy.ts @@ -1,8 +1,8 @@ -import { DocumentNode } from 'graphql'; // ignore-comment eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { DocumentNode } from 'graphql'; // ignore-comment eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; -import { MissingFieldError } from './common'; -import { Reference } from '../../../utilities'; +import type { MissingFieldError } from './common'; +import type { Reference } from '../../../utilities'; export namespace DataProxy { export interface Query { diff --git a/src/cache/core/types/common.ts b/src/cache/core/types/common.ts index 176332b8332..4e45b84ad82 100644 --- a/src/cache/core/types/common.ts +++ b/src/cache/core/types/common.ts @@ -1,13 +1,13 @@ -import { DocumentNode, FieldNode } from 'graphql'; +import type { DocumentNode, FieldNode } from 'graphql'; -import { +import type { Reference, StoreObject, StoreValue, isReference, } from '../../../utilities'; -import { StorageType } from '../../inmemory/policies'; +import type { StorageType } from '../../inmemory/policies'; // The Readonly type only really works for object types, since it marks // all of the object's properties as readonly, but there are many cases when diff --git a/src/cache/inmemory/entityStore.ts b/src/cache/inmemory/entityStore.ts index f5fbf610b43..9631ca615ef 100644 --- a/src/cache/inmemory/entityStore.ts +++ b/src/cache/inmemory/entityStore.ts @@ -1,24 +1,26 @@ import { invariant } from '../../utilities/globals'; -import { dep, OptimisticDependencyFunction } from 'optimism'; +import type { OptimisticDependencyFunction } from 'optimism'; +import { dep } from 'optimism'; import { equal } from '@wry/equality'; import { Trie } from '@wry/trie'; -import { - isReference, +import type { StoreValue, StoreObject, - Reference, + Reference} from '../../utilities'; +import { + isReference, makeReference, DeepMerger, maybeDeepFreeze, canUseWeakMap, isNonNullObject, } from '../../utilities'; -import { NormalizedCache, NormalizedCacheObject } from './types'; +import type { NormalizedCache, NormalizedCacheObject } from './types'; import { hasOwn, fieldNameFromStoreName } from './helpers'; -import { Policies, StorageType } from './policies'; -import { Cache } from '../core/types/Cache'; -import { +import type { Policies, StorageType } from './policies'; +import type { Cache } from '../core/types/Cache'; +import type { SafeReadonly, Modifier, Modifiers, diff --git a/src/cache/inmemory/fragmentRegistry.ts b/src/cache/inmemory/fragmentRegistry.ts index 3756b9022ca..8709a26d95f 100644 --- a/src/cache/inmemory/fragmentRegistry.ts +++ b/src/cache/inmemory/fragmentRegistry.ts @@ -1,14 +1,16 @@ -import { +import type { DocumentNode, ASTNode, FragmentDefinitionNode, - FragmentSpreadNode, + FragmentSpreadNode} from "graphql"; +import { visit, } from "graphql"; import { wrap } from "optimism"; -import { FragmentMap, getFragmentDefinitions } from "../../utilities"; +import type { FragmentMap} from "../../utilities"; +import { getFragmentDefinitions } from "../../utilities"; export interface FragmentRegistryAPI { register(...fragments: DocumentNode[]): this; diff --git a/src/cache/inmemory/helpers.ts b/src/cache/inmemory/helpers.ts index 116be355954..06f6c0b5311 100644 --- a/src/cache/inmemory/helpers.ts +++ b/src/cache/inmemory/helpers.ts @@ -1,26 +1,27 @@ -import { DocumentNode, FragmentDefinitionNode, SelectionSetNode } from 'graphql'; +import type { DocumentNode, FragmentDefinitionNode, SelectionSetNode } from 'graphql'; -import { +import type { NormalizedCache, InMemoryCacheConfig, } from './types'; -import { KeyFieldsContext } from './policies'; -import { FragmentRegistryAPI } from './fragmentRegistry'; +import type { KeyFieldsContext } from './policies'; +import type { FragmentRegistryAPI } from './fragmentRegistry'; -import { +import type { Reference, - isReference, StoreValue, StoreObject, + FragmentMap, + FragmentMapFunction} from '../../utilities'; +import { + isReference, isField, DeepMerger, resultKeyNameFromField, shouldInclude, isNonNullObject, compact, - FragmentMap, - FragmentMapFunction, createFragmentMap, getFragmentDefinitions, isArray, diff --git a/src/cache/inmemory/inMemoryCache.ts b/src/cache/inmemory/inMemoryCache.ts index 3ff418ffbb9..c9df262ddf5 100644 --- a/src/cache/inmemory/inMemoryCache.ts +++ b/src/cache/inmemory/inMemoryCache.ts @@ -3,20 +3,22 @@ import { invariant } from '../../utilities/globals'; // Make builtins like Map and Set safe to use with non-extensible objects. import './fixPolyfills'; -import { DocumentNode } from 'graphql'; -import { OptimisticWrapperFunction, wrap } from 'optimism'; +import type { DocumentNode } from 'graphql'; +import type { OptimisticWrapperFunction} from 'optimism'; +import { wrap } from 'optimism'; import { equal } from '@wry/equality'; import { ApolloCache } from '../core/cache'; -import { Cache } from '../core/types/Cache'; +import type { Cache } from '../core/types/Cache'; import { MissingFieldError } from '../core/types/common'; +import type { + StoreObject, + Reference} from '../../utilities'; import { addTypenameToDocument, - StoreObject, - Reference, isReference, } from '../../utilities'; -import { InMemoryCacheConfig, NormalizedCacheObject } from './types'; +import type { InMemoryCacheConfig, NormalizedCacheObject } from './types'; import { StoreReader } from './readFromStore'; import { StoreWriter } from './writeToStore'; import { EntityStore, supportsResultCaching } from './entityStore'; @@ -24,7 +26,7 @@ import { makeVar, forgetCache, recallCache } from './reactiveVars'; import { Policies } from './policies'; import { hasOwn, normalizeConfig, shouldCanonizeResults } from './helpers'; import { canonicalStringify } from './object-canon'; -import { OperationVariables } from '../../core'; +import type { OperationVariables } from '../../core'; type BroadcastOptions = Pick< Cache.BatchOptions, diff --git a/src/cache/inmemory/key-extractor.ts b/src/cache/inmemory/key-extractor.ts index 3f1fdd6476f..58c56777782 100644 --- a/src/cache/inmemory/key-extractor.ts +++ b/src/cache/inmemory/key-extractor.ts @@ -8,7 +8,7 @@ import { } from "../../utilities"; import { hasOwn, isArray } from "./helpers"; -import { +import type { KeySpecifier, KeyFieldsFunction, KeyArgsFunction, diff --git a/src/cache/inmemory/policies.ts b/src/cache/inmemory/policies.ts index 121ef24ffd8..7af4ceddcac 100644 --- a/src/cache/inmemory/policies.ts +++ b/src/cache/inmemory/policies.ts @@ -1,25 +1,26 @@ import { invariant, InvariantError, __DEV__ } from '../../utilities/globals'; -import { +import type { InlineFragmentNode, FragmentDefinitionNode, SelectionSetNode, FieldNode, } from 'graphql'; -import { +import type { FragmentMap, - storeKeyNameFromField, StoreValue, StoreObject, + Reference} from '../../utilities'; +import { + storeKeyNameFromField, argumentsObjectFromField, - Reference, isReference, getStoreKeyName, isNonNullObject, stringifyForDisplay, } from '../../utilities'; -import { +import type { IdGetter, MergeInfo, NormalizedCache, @@ -35,8 +36,8 @@ import { isArray, } from './helpers'; import { cacheSlot } from './reactiveVars'; -import { InMemoryCache } from './inMemoryCache'; -import { +import type { InMemoryCache } from './inMemoryCache'; +import type { SafeReadonly, FieldSpecifier, ToReferenceFunction, @@ -44,7 +45,7 @@ import { ReadFieldOptions, CanReadFunction, } from '../core/types/common'; -import { WriteContext } from './writeToStore'; +import type { WriteContext } from './writeToStore'; // Upgrade to a faster version of the default stable JSON.stringify function // used by getStoreKeyName. This function is used when computing storeFieldName diff --git a/src/cache/inmemory/reactiveVars.ts b/src/cache/inmemory/reactiveVars.ts index f15c54c62a5..9e347f35f4a 100644 --- a/src/cache/inmemory/reactiveVars.ts +++ b/src/cache/inmemory/reactiveVars.ts @@ -1,7 +1,8 @@ -import { dep, OptimisticDependencyFunction } from "optimism"; +import type { OptimisticDependencyFunction } from "optimism"; +import { dep } from "optimism"; import { Slot } from "@wry/context"; -import { InMemoryCache } from "./inMemoryCache"; -import { ApolloCache } from '../../core'; +import type { InMemoryCache } from "./inMemoryCache"; +import type { ApolloCache } from '../../core'; export interface ReactiveVar { (newValue?: T): T; diff --git a/src/cache/inmemory/readFromStore.ts b/src/cache/inmemory/readFromStore.ts index 2ae56785e40..1ba72a639ea 100644 --- a/src/cache/inmemory/readFromStore.ts +++ b/src/cache/inmemory/readFromStore.ts @@ -1,21 +1,25 @@ import { invariant, InvariantError, __DEV__ } from '../../utilities/globals'; -import { +import type { DocumentNode, FieldNode, - Kind, - SelectionSetNode, + SelectionSetNode} from 'graphql'; +import { + Kind } from 'graphql'; -import { wrap, OptimisticWrapperFunction } from 'optimism'; +import type { OptimisticWrapperFunction } from 'optimism'; +import { wrap } from 'optimism'; +import type { + Reference, + StoreObject, + FragmentMap, + FragmentMapFunction} from '../../utilities'; import { isField, resultKeyNameFromField, - Reference, isReference, makeReference, - StoreObject, - FragmentMap, shouldInclude, addTypenameToDocument, getDefaultValues, @@ -27,11 +31,10 @@ import { DeepMerger, isNonNullObject, canUseWeakMap, - compact, - FragmentMapFunction, + compact } from '../../utilities'; -import { Cache } from '../core/types/Cache'; -import { +import type { Cache } from '../core/types/Cache'; +import type { DiffQueryAgainstStoreOptions, InMemoryCacheConfig, NormalizedCache, @@ -39,9 +42,10 @@ import { } from './types'; import { maybeDependOnExistenceOfEntity, supportsResultCaching } from './entityStore'; import { isArray, extractFragmentContext, getTypenameFromStoreObject, shouldCanonizeResults } from './helpers'; -import { Policies } from './policies'; -import { InMemoryCache } from './inMemoryCache'; -import { MissingFieldError, MissingTree } from '../core/types/common'; +import type { Policies } from './policies'; +import type { InMemoryCache } from './inMemoryCache'; +import type { MissingTree } from '../core/types/common'; +import { MissingFieldError } from '../core/types/common'; import { canonicalStringify, ObjectCanon } from './object-canon'; export type VariableMap = { [name: string]: any }; diff --git a/src/cache/inmemory/types.ts b/src/cache/inmemory/types.ts index d6a52ef809e..31a06caa20a 100644 --- a/src/cache/inmemory/types.ts +++ b/src/cache/inmemory/types.ts @@ -1,27 +1,27 @@ -import { DocumentNode, FieldNode } from 'graphql'; +import type { DocumentNode, FieldNode } from 'graphql'; -import { Transaction } from '../core/cache'; +import type { Transaction } from '../core/cache'; import { StoreObject, StoreValue, Reference, } from '../../utilities'; -import { FieldValueGetter } from './entityStore'; -import { +import type { FieldValueGetter } from './entityStore'; +import type { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction, } from './policies'; -import { +import type { Modifier, Modifiers, ToReferenceFunction, CanReadFunction, } from '../core/types/common'; -import { FragmentRegistryAPI } from './fragmentRegistry'; +import type { FragmentRegistryAPI } from './fragmentRegistry'; export { StoreObject, StoreValue, Reference } diff --git a/src/cache/inmemory/writeToStore.ts b/src/cache/inmemory/writeToStore.ts index a778749b253..9076e91b7fd 100644 --- a/src/cache/inmemory/writeToStore.ts +++ b/src/cache/inmemory/writeToStore.ts @@ -1,15 +1,20 @@ import { invariant, InvariantError, __DEV__ } from '../../utilities/globals'; import { equal } from '@wry/equality'; import { Trie } from '@wry/trie'; -import { +import type { SelectionSetNode, - FieldNode, + FieldNode} from 'graphql'; +import { Kind, } from 'graphql'; -import { +import type { FragmentMap, FragmentMapFunction, + StoreValue, + StoreObject, + Reference} from '../../utilities'; +import { getFragmentFromSelection, getDefaultValues, getOperationDefinition, @@ -17,9 +22,6 @@ import { makeReference, isField, resultKeyNameFromField, - StoreValue, - StoreObject, - Reference, isReference, shouldInclude, cloneDeep, @@ -28,15 +30,15 @@ import { argumentsObjectFromField, } from '../../utilities'; -import { NormalizedCache, ReadMergeModifyContext, MergeTree, InMemoryCacheConfig } from './types'; +import type { NormalizedCache, ReadMergeModifyContext, MergeTree, InMemoryCacheConfig } from './types'; import { isArray, makeProcessedFieldsMerger, fieldNameFromStoreName, storeValueIsStoreObject, extractFragmentContext } from './helpers'; -import { StoreReader } from './readFromStore'; -import { InMemoryCache } from './inMemoryCache'; -import { EntityStore } from './entityStore'; -import { Cache } from '../../core'; +import type { StoreReader } from './readFromStore'; +import type { InMemoryCache } from './inMemoryCache'; +import type { EntityStore } from './entityStore'; +import type { Cache } from '../../core'; import { canonicalStringify } from './object-canon'; import { normalizeReadFieldOptions } from './policies'; -import { ReadFieldFunction } from '../core/types/common'; +import type { ReadFieldFunction } from '../core/types/common'; export interface WriteContext extends ReadMergeModifyContext { readonly written: { diff --git a/src/core/ApolloClient.ts b/src/core/ApolloClient.ts index ea7ea6a210e..112a505f33b 100644 --- a/src/core/ApolloClient.ts +++ b/src/core/ApolloClient.ts @@ -1,17 +1,19 @@ import { invariant, InvariantError, __DEV__ } from '../utilities/globals'; -import { ExecutionResult, DocumentNode } from 'graphql'; +import type { ExecutionResult, DocumentNode } from 'graphql'; -import { ApolloLink, FetchResult, GraphQLRequest, execute } from '../link/core'; -import { ApolloCache, DataProxy, Reference } from '../cache'; -import { Observable } from '../utilities'; +import type { FetchResult, GraphQLRequest} from '../link/core'; +import { ApolloLink, execute } from '../link/core'; +import type { ApolloCache, DataProxy, Reference } from '../cache'; +import type { Observable } from '../utilities'; import { version } from '../version'; -import { HttpLink, UriFunction } from '../link/http'; +import type { UriFunction } from '../link/http'; +import { HttpLink } from '../link/http'; import { QueryManager } from './QueryManager'; -import { ObservableQuery } from './ObservableQuery'; +import type { ObservableQuery } from './ObservableQuery'; -import { +import type { ApolloQueryResult, DefaultContext, OperationVariables, @@ -23,7 +25,7 @@ import { TransformQueryOptions, } from './types'; -import { +import type { QueryOptions, WatchQueryOptions, MutationOptions, @@ -31,9 +33,10 @@ import { WatchQueryFetchPolicy, } from './watchQueryOptions'; +import type { + FragmentMatcher} from './LocalState'; import { - LocalState, - FragmentMatcher, + LocalState } from './LocalState'; export interface DefaultOptions { diff --git a/src/core/LocalState.ts b/src/core/LocalState.ts index e209f4bccc4..e2ede24f53c 100644 --- a/src/core/LocalState.ts +++ b/src/core/LocalState.ts @@ -1,6 +1,6 @@ import { invariant } from '../utilities/globals'; -import { +import type { DocumentNode, OperationDefinitionNode, SelectionSetNode, @@ -9,18 +9,20 @@ import { FragmentDefinitionNode, FieldNode, ASTNode, - visit, - BREAK, - isSelectionNode, DirectiveNode, FragmentSpreadNode, - ExecutableDefinitionNode, + ExecutableDefinitionNode} from 'graphql'; +import { + visit, + BREAK, + isSelectionNode } from 'graphql'; -import { ApolloCache } from '../cache'; -import { +import type { ApolloCache } from '../cache'; +import type { FragmentMap, - StoreObject, + StoreObject} from '../utilities'; +import { argumentsObjectFromField, buildQueryFromSelectionSet, createFragmentMap, @@ -35,9 +37,9 @@ import { resultKeyNameFromField, shouldInclude, } from '../utilities'; -import { ApolloClient } from './ApolloClient'; -import { Resolvers, OperationVariables } from './types'; -import { FetchResult } from '../link/core'; +import type { ApolloClient } from './ApolloClient'; +import type { Resolvers, OperationVariables } from './types'; +import type { FetchResult } from '../link/core'; import { cacheSlot } from '../cache'; export type Resolver = ( diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index 8a5b24618d0..b3bbd7b6240 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -1,36 +1,37 @@ import { invariant, __DEV__ } from '../utilities/globals'; -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import { equal } from '@wry/equality'; import { NetworkStatus, isNetworkRequestInFlight } from './networkStatus'; -import { +import type { Concast, + Observer, + ObservableSubscription} from '../utilities'; +import { cloneDeep, compact, getOperationDefinition, Observable, - Observer, - ObservableSubscription, iterateObserversSafely, fixObservableSubclass, getQueryDefinition, } from '../utilities'; -import { ApolloError } from '../errors'; -import { QueryManager } from './QueryManager'; -import { +import type { ApolloError } from '../errors'; +import type { QueryManager } from './QueryManager'; +import type { ApolloQueryResult, OperationVariables, TypedDocumentNode, } from './types'; -import { +import type { WatchQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, NextFetchPolicyContext, } from './watchQueryOptions'; -import { QueryInfo } from './QueryInfo'; -import { MissingFieldError } from '../cache'; -import { MissingTree } from '../cache/core/types/common'; +import type { QueryInfo } from './QueryInfo'; +import type { MissingFieldError } from '../cache'; +import type { MissingTree } from '../cache/core/types/common'; import { equalByQuery } from './equalByQuery'; const { diff --git a/src/core/QueryInfo.ts b/src/core/QueryInfo.ts index 1e95fc3849a..1ce6377c40b 100644 --- a/src/core/QueryInfo.ts +++ b/src/core/QueryInfo.ts @@ -1,15 +1,17 @@ -import { DocumentNode, GraphQLError } from 'graphql'; +import type { DocumentNode, GraphQLError } from 'graphql'; import { equal } from "@wry/equality"; -import { Cache, ApolloCache } from '../cache'; +import type { Cache, ApolloCache } from '../cache'; import { DeepMerger } from "../utilities" import { mergeIncrementalData } from '../utilities'; -import { WatchQueryOptions, ErrorPolicy } from './watchQueryOptions'; -import { ObservableQuery, reobserveCacheFirst } from './ObservableQuery'; -import { QueryListener, MethodKeys } from './types'; -import { FetchResult } from '../link/core'; +import type { WatchQueryOptions, ErrorPolicy } from './watchQueryOptions'; +import type { ObservableQuery} from './ObservableQuery'; +import { reobserveCacheFirst } from './ObservableQuery'; +import type { QueryListener, MethodKeys } from './types'; +import type { FetchResult } from '../link/core'; +import type { + ObservableSubscription} from '../utilities'; import { - ObservableSubscription, isNonEmptyArray, graphQLResultHasError, canUseWeakMap, @@ -18,8 +20,8 @@ import { NetworkStatus, isNetworkRequestInFlight, } from './networkStatus'; -import { ApolloError } from '../errors'; -import { QueryManager } from './QueryManager'; +import type { ApolloError } from '../errors'; +import type { QueryManager } from './QueryManager'; export type QueryStoreValue = Pick; diff --git a/src/link/error/index.ts b/src/link/error/index.ts index 110383880b7..9f004f2afef 100644 --- a/src/link/error/index.ts +++ b/src/link/error/index.ts @@ -1,8 +1,9 @@ -import { ExecutionResult } from 'graphql'; +import type { ExecutionResult } from 'graphql'; -import { NetworkError, GraphQLErrors } from '../../errors'; +import type { NetworkError, GraphQLErrors } from '../../errors'; import { Observable } from '../../utilities'; -import { ApolloLink, Operation, FetchResult, NextLink } from '../core'; +import type { Operation, FetchResult, NextLink } from '../core'; +import { ApolloLink } from '../core'; export interface ErrorResponse { graphQLErrors?: GraphQLErrors; diff --git a/src/link/http/HttpLink.ts b/src/link/http/HttpLink.ts index cc2a8d5fa14..e44dafb92e3 100644 --- a/src/link/http/HttpLink.ts +++ b/src/link/http/HttpLink.ts @@ -1,5 +1,6 @@ -import { ApolloLink, RequestHandler } from '../core'; -import { HttpOptions } from './selectHttpOptionsAndBody'; +import type { RequestHandler } from '../core'; +import { ApolloLink } from '../core'; +import type { HttpOptions } from './selectHttpOptionsAndBody'; import { createHttpLink } from './createHttpLink'; export class HttpLink extends ApolloLink { diff --git a/src/link/http/createHttpLink.ts b/src/link/http/createHttpLink.ts index 0a86b7a1979..48a9170cf01 100644 --- a/src/link/http/createHttpLink.ts +++ b/src/link/http/createHttpLink.ts @@ -1,6 +1,6 @@ import { __DEV__, invariant } from '../../utilities/globals'; -import { DefinitionNode } from 'graphql'; +import type { DefinitionNode } from 'graphql'; import { ApolloLink } from '../core'; import { Observable, hasDirectives } from '../../utilities'; @@ -12,11 +12,13 @@ import { readJsonBody } from './parseAndCheckHttpResponse'; import { checkFetcher } from './checkFetcher'; +import type { + HttpOptions +} from './selectHttpOptionsAndBody'; import { selectHttpOptionsAndBodyInternal, defaultPrinter, - fallbackHttpConfig, - HttpOptions + fallbackHttpConfig } from './selectHttpOptionsAndBody'; import { createSignalIfSupported } from './createSignalIfSupported'; import { rewriteURIForGET } from './rewriteURIForGET'; diff --git a/src/link/http/iterators/nodeStream.ts b/src/link/http/iterators/nodeStream.ts index c0e00664c4e..4690f649c84 100644 --- a/src/link/http/iterators/nodeStream.ts +++ b/src/link/http/iterators/nodeStream.ts @@ -3,7 +3,7 @@ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/nodeStream.ts */ -import { Readable as NodeReadableStream } from "stream"; +import type { Readable as NodeReadableStream } from "stream"; import { canUseAsyncIteratorSymbol } from "../../../utilities"; interface NodeStreamIterator { diff --git a/src/link/http/parseAndCheckHttpResponse.ts b/src/link/http/parseAndCheckHttpResponse.ts index ba9307ac9e2..ac5d7e6a3b1 100644 --- a/src/link/http/parseAndCheckHttpResponse.ts +++ b/src/link/http/parseAndCheckHttpResponse.ts @@ -1,8 +1,8 @@ import { responseIterator } from "./responseIterator"; -import { Operation } from "../core"; +import type { Operation } from "../core"; import { throwServerError } from "../utils"; import { PROTOCOL_ERRORS_SYMBOL } from '../../errors'; -import { Observer } from "../../utilities"; +import type { Observer } from "../../utilities"; import { isApolloPayloadResult } from '../../utilities/common/incrementalResult'; diff --git a/src/link/http/responseIterator.ts b/src/link/http/responseIterator.ts index 4698890a452..75e82df457b 100644 --- a/src/link/http/responseIterator.ts +++ b/src/link/http/responseIterator.ts @@ -3,7 +3,7 @@ * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts */ -import { Response as NodeResponse } from "node-fetch"; +import type { Response as NodeResponse } from "node-fetch"; import { isAsyncIterableIterator, isBlob, diff --git a/src/link/http/rewriteURIForGET.ts b/src/link/http/rewriteURIForGET.ts index 5b7af5b3209..446a903b630 100644 --- a/src/link/http/rewriteURIForGET.ts +++ b/src/link/http/rewriteURIForGET.ts @@ -1,5 +1,5 @@ import { serializeFetchParameter } from './serializeFetchParameter'; -import { Body } from './selectHttpOptionsAndBody'; +import type { Body } from './selectHttpOptionsAndBody'; // For GET operations, returns the given URI rewritten with parameters, or a // parse error. diff --git a/src/link/http/selectHttpOptionsAndBody.ts b/src/link/http/selectHttpOptionsAndBody.ts index 82aa11dc9ce..ab7b6704a4a 100644 --- a/src/link/http/selectHttpOptionsAndBody.ts +++ b/src/link/http/selectHttpOptionsAndBody.ts @@ -1,7 +1,8 @@ -import { ASTNode, print } from 'graphql'; +import type { ASTNode} from 'graphql'; +import { print } from 'graphql'; import { stripTypename } from '../../utilities'; -import { Operation } from '../core'; +import type { Operation } from '../core'; export interface Printer { (node: ASTNode, originalPrint: typeof print): string diff --git a/src/link/http/selectURI.ts b/src/link/http/selectURI.ts index 461098f2e2e..fb8f50f9789 100644 --- a/src/link/http/selectURI.ts +++ b/src/link/http/selectURI.ts @@ -1,4 +1,4 @@ -import { Operation } from '../core'; +import type { Operation } from '../core'; export const selectURI = ( operation: Operation, diff --git a/src/link/persisted-queries/index.ts b/src/link/persisted-queries/index.ts index 3123dc7bdec..7543ed2c97d 100644 --- a/src/link/persisted-queries/index.ts +++ b/src/link/persisted-queries/index.ts @@ -1,22 +1,24 @@ import { invariant } from '../../utilities/globals'; import { print } from 'graphql'; -import { +import type { DocumentNode, ExecutionResult, GraphQLError, } from 'graphql'; -import { ApolloLink, Operation } from '../core'; +import type { Operation } from '../core'; +import { ApolloLink } from '../core'; +import type { + Observer, + ObservableSubscription} from '../../utilities'; import { Observable, - Observer, - ObservableSubscription, compact, isNonEmptyArray, } from '../../utilities'; -import { NetworkError } from '../../errors'; -import { ServerError } from '../utils'; +import type { NetworkError } from '../../errors'; +import type { ServerError } from '../utils'; export const VERSION = 1; diff --git a/src/link/retry/delayFunction.ts b/src/link/retry/delayFunction.ts index 2b4bb3f2cc1..c6e2552e1ac 100644 --- a/src/link/retry/delayFunction.ts +++ b/src/link/retry/delayFunction.ts @@ -1,4 +1,4 @@ -import { Operation } from '../core'; +import type { Operation } from '../core'; /** * Advanced mode: a function that implements the strategy for calculating delays diff --git a/src/link/retry/retryFunction.ts b/src/link/retry/retryFunction.ts index 891a76317b6..d5653b36c21 100644 --- a/src/link/retry/retryFunction.ts +++ b/src/link/retry/retryFunction.ts @@ -1,4 +1,4 @@ -import { Operation } from '../core'; +import type { Operation } from '../core'; /** * Advanced mode: a function that determines both whether a particular diff --git a/src/link/retry/retryLink.ts b/src/link/retry/retryLink.ts index 1afa7ae9604..4aa2a9c0933 100644 --- a/src/link/retry/retryLink.ts +++ b/src/link/retry/retryLink.ts @@ -1,13 +1,17 @@ -import { ApolloLink, Operation, FetchResult, NextLink } from '../core'; -import { Observable, Observer, ObservableSubscription } from '../../utilities'; -import { +import type { Operation, FetchResult, NextLink } from '../core'; +import { ApolloLink } from '../core'; +import type { Observer, ObservableSubscription } from '../../utilities'; +import { Observable } from '../../utilities'; +import type { DelayFunction, - DelayFunctionOptions, + DelayFunctionOptions} from './delayFunction'; +import { buildDelayFunction, } from './delayFunction'; -import { +import type { RetryFunction, - RetryFunctionOptions, + RetryFunctionOptions} from './retryFunction'; +import { buildRetryFunction, } from './retryFunction'; diff --git a/src/link/schema/index.ts b/src/link/schema/index.ts index 9cda33dd189..6616fd3281e 100644 --- a/src/link/schema/index.ts +++ b/src/link/schema/index.ts @@ -1,6 +1,8 @@ -import { validate, execute, GraphQLSchema } from 'graphql'; +import type { GraphQLSchema } from 'graphql'; +import { validate, execute } from 'graphql'; -import { ApolloLink, Operation, FetchResult } from '../core'; +import type { Operation, FetchResult } from '../core'; +import { ApolloLink } from '../core'; import { Observable } from '../../utilities'; export namespace SchemaLink { diff --git a/src/link/subscriptions/index.ts b/src/link/subscriptions/index.ts index 86fce19ccda..9a9b88c22c1 100644 --- a/src/link/subscriptions/index.ts +++ b/src/link/subscriptions/index.ts @@ -31,7 +31,8 @@ import { print } from "graphql"; import type { Client } from "graphql-ws"; -import { ApolloLink, Operation, FetchResult } from "../core"; +import type { Operation, FetchResult } from "../core"; +import { ApolloLink } from "../core"; import { isNonNullObject, stripTypename, Observable } from "../../utilities"; import { ApolloError } from "../../errors"; diff --git a/src/link/utils/createOperation.ts b/src/link/utils/createOperation.ts index 8970e3595d1..39c0f1d9041 100644 --- a/src/link/utils/createOperation.ts +++ b/src/link/utils/createOperation.ts @@ -1,4 +1,4 @@ -import { GraphQLRequest, Operation } from '../core'; +import type { GraphQLRequest, Operation } from '../core'; export function createOperation( starting: any, diff --git a/src/link/utils/filterOperationVariables.ts b/src/link/utils/filterOperationVariables.ts index 9c182803ae9..8f1b9528903 100644 --- a/src/link/utils/filterOperationVariables.ts +++ b/src/link/utils/filterOperationVariables.ts @@ -1,6 +1,7 @@ -import { VariableDefinitionNode, visit } from "graphql"; +import type { VariableDefinitionNode} from "graphql"; +import { visit } from "graphql"; -import { Operation } from "../core"; +import type { Operation } from "../core"; export function filterOperationVariables(variables: Record, operation: Operation) { const result = { ...variables }; diff --git a/src/link/utils/toPromise.ts b/src/link/utils/toPromise.ts index 505de89ec75..55b4b87b482 100644 --- a/src/link/utils/toPromise.ts +++ b/src/link/utils/toPromise.ts @@ -1,5 +1,5 @@ import { invariant } from '../../utilities/globals'; -import { Observable } from '../../utilities'; +import type { Observable } from '../../utilities'; export function toPromise(observable: Observable): Promise { let completed = false; diff --git a/src/link/utils/transformOperation.ts b/src/link/utils/transformOperation.ts index 41a54ce48f1..a7fece2e221 100644 --- a/src/link/utils/transformOperation.ts +++ b/src/link/utils/transformOperation.ts @@ -1,4 +1,4 @@ -import { GraphQLRequest, Operation } from '../core'; +import type { GraphQLRequest, Operation } from '../core'; import { getOperationName } from '../../utilities'; export function transformOperation(operation: GraphQLRequest): GraphQLRequest { diff --git a/src/link/utils/validateOperation.ts b/src/link/utils/validateOperation.ts index a269776111a..e02cceb70a7 100644 --- a/src/link/utils/validateOperation.ts +++ b/src/link/utils/validateOperation.ts @@ -1,5 +1,5 @@ import { InvariantError } from '../../utilities/globals' -import { GraphQLRequest } from '../core'; +import type { GraphQLRequest } from '../core'; export function validateOperation(operation: GraphQLRequest): GraphQLRequest { const OPERATION_FIELDS = [ diff --git a/src/link/ws/index.ts b/src/link/ws/index.ts index 1cc1fffa0d6..21d77e2b49b 100644 --- a/src/link/ws/index.ts +++ b/src/link/ws/index.ts @@ -1,7 +1,9 @@ -import { SubscriptionClient, ClientOptions } from 'subscriptions-transport-ws'; +import type { ClientOptions } from 'subscriptions-transport-ws'; +import { SubscriptionClient } from 'subscriptions-transport-ws'; -import { ApolloLink, Operation, FetchResult } from '../core'; -import { Observable } from '../../utilities'; +import type { Operation, FetchResult } from '../core'; +import { ApolloLink } from '../core'; +import type { Observable } from '../../utilities'; export namespace WebSocketLink { /** diff --git a/src/react/cache/QuerySubscription.ts b/src/react/cache/QuerySubscription.ts index 4c2503d6d01..9913dbf3306 100644 --- a/src/react/cache/QuerySubscription.ts +++ b/src/react/cache/QuerySubscription.ts @@ -1,13 +1,15 @@ -import { +import type { ApolloError, ApolloQueryResult, - NetworkStatus, ObservableQuery, - OperationVariables, + OperationVariables} from '../../core'; +import { + NetworkStatus } from '../../core'; import { isNetworkRequestSettled } from '../../core'; +import type { + ObservableSubscription} from '../../utilities'; import { - ObservableSubscription, createFulfilledPromise, createRejectedPromise, } from '../../utilities'; diff --git a/src/react/cache/SuspenseCache.ts b/src/react/cache/SuspenseCache.ts index b9341f85451..a6f9f6d03f8 100644 --- a/src/react/cache/SuspenseCache.ts +++ b/src/react/cache/SuspenseCache.ts @@ -1,5 +1,5 @@ import { Trie } from '@wry/trie'; -import { ObservableQuery } from '../../core'; +import type { ObservableQuery } from '../../core'; import { canUseWeakMap } from '../../utilities'; import { QuerySubscription } from './QuerySubscription'; diff --git a/src/react/components/Mutation.tsx b/src/react/components/Mutation.tsx index f4ebc454bbd..8e6d19909f4 100644 --- a/src/react/components/Mutation.tsx +++ b/src/react/components/Mutation.tsx @@ -1,7 +1,7 @@ import * as PropTypes from 'prop-types'; -import { OperationVariables } from '../../core'; -import { MutationComponentOptions } from './types'; +import type { OperationVariables } from '../../core'; +import type { MutationComponentOptions } from './types'; import { useMutation } from '../hooks'; export function Mutation( diff --git a/src/react/components/Query.tsx b/src/react/components/Query.tsx index a30445d901f..bb6956ce931 100644 --- a/src/react/components/Query.tsx +++ b/src/react/components/Query.tsx @@ -1,7 +1,7 @@ import * as PropTypes from 'prop-types'; -import { OperationVariables } from '../../core'; -import { QueryComponentOptions } from './types'; +import type { OperationVariables } from '../../core'; +import type { QueryComponentOptions } from './types'; import { useQuery } from '../hooks'; export function Query( diff --git a/src/react/components/Subscription.tsx b/src/react/components/Subscription.tsx index 0ffcca767c6..ab448939c95 100644 --- a/src/react/components/Subscription.tsx +++ b/src/react/components/Subscription.tsx @@ -1,7 +1,7 @@ import * as PropTypes from 'prop-types'; -import { OperationVariables } from '../../core'; -import { SubscriptionComponentOptions } from './types'; +import type { OperationVariables } from '../../core'; +import type { SubscriptionComponentOptions } from './types'; import { useSubscription } from '../hooks'; export function Subscription( diff --git a/src/react/components/types.ts b/src/react/components/types.ts index 2e12fe43afe..b99387ed96c 100644 --- a/src/react/components/types.ts +++ b/src/react/components/types.ts @@ -1,8 +1,8 @@ -import { DocumentNode } from 'graphql'; -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { DocumentNode } from 'graphql'; +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; -import { OperationVariables, DefaultContext, ApolloCache } from '../../core'; -import { +import type { OperationVariables, DefaultContext, ApolloCache } from '../../core'; +import type { QueryFunctionOptions, QueryResult, BaseMutationOptions, diff --git a/src/react/context/ApolloConsumer.tsx b/src/react/context/ApolloConsumer.tsx index 02b8924806e..7cbd84aecd3 100644 --- a/src/react/context/ApolloConsumer.tsx +++ b/src/react/context/ApolloConsumer.tsx @@ -2,7 +2,7 @@ import { invariant } from '../../utilities/globals'; import * as React from 'react'; -import { ApolloClient } from '../../core'; +import type { ApolloClient } from '../../core'; import { getApolloContext } from './ApolloContext'; export interface ApolloConsumerProps { diff --git a/src/react/context/ApolloContext.ts b/src/react/context/ApolloContext.ts index 2453a6356de..bb97b89a3e0 100644 --- a/src/react/context/ApolloContext.ts +++ b/src/react/context/ApolloContext.ts @@ -1,7 +1,7 @@ import * as React from 'react'; -import { ApolloClient } from '../../core'; +import type { ApolloClient } from '../../core'; import { canUseSymbol } from '../../utilities'; -import { SuspenseCache } from '../cache'; +import type { SuspenseCache } from '../cache'; import type { RenderPromises } from '../ssr'; export interface ApolloContextValue { diff --git a/src/react/context/ApolloProvider.tsx b/src/react/context/ApolloProvider.tsx index c00a0d539e6..45d3ca2c657 100644 --- a/src/react/context/ApolloProvider.tsx +++ b/src/react/context/ApolloProvider.tsx @@ -2,9 +2,9 @@ import { invariant } from '../../utilities/globals'; import * as React from 'react'; -import { ApolloClient } from '../../core'; +import type { ApolloClient } from '../../core'; import { getApolloContext } from './ApolloContext'; -import { SuspenseCache } from '../cache'; +import type { SuspenseCache } from '../cache'; export interface ApolloProviderProps { client: ApolloClient; diff --git a/src/react/hoc/graphql.tsx b/src/react/hoc/graphql.tsx index 4949f1d7241..09e453bec2a 100644 --- a/src/react/hoc/graphql.tsx +++ b/src/react/hoc/graphql.tsx @@ -1,11 +1,11 @@ -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import { parser, DocumentType } from '../parser'; import { withQuery } from './query-hoc'; import { withMutation } from './mutation-hoc'; import { withSubscription } from './subscription-hoc'; -import { OperationOption, DataProps, MutateProps } from './types'; -import { OperationVariables } from '../../core'; +import type { OperationOption, DataProps, MutateProps } from './types'; +import type { OperationVariables } from '../../core'; export function graphql< TProps extends TGraphQLVariables | {} = {}, diff --git a/src/react/hoc/hoc-utils.tsx b/src/react/hoc/hoc-utils.tsx index 18b4bc9f28b..7a8589b2993 100644 --- a/src/react/hoc/hoc-utils.tsx +++ b/src/react/hoc/hoc-utils.tsx @@ -1,7 +1,7 @@ import { invariant } from '../../utilities/globals'; import * as React from 'react'; -import { OperationVariables } from '../../core'; -import { IDocumentDefinition } from '../parser'; +import type { OperationVariables } from '../../core'; +import type { IDocumentDefinition } from '../parser'; export const defaultMapPropsToOptions = () => ({}); export const defaultMapResultToProps:

(props: P) => P = props => props; diff --git a/src/react/hoc/mutation-hoc.tsx b/src/react/hoc/mutation-hoc.tsx index c6b59130c5c..2732313c443 100644 --- a/src/react/hoc/mutation-hoc.tsx +++ b/src/react/hoc/mutation-hoc.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { parser } from '../parser'; -import { DefaultContext, OperationVariables } from '../../core/types'; -import { +import type { DefaultContext, OperationVariables } from '../../core/types'; +import type { BaseMutationOptions, MutationFunction, MutationResult @@ -17,8 +17,8 @@ import { calculateVariablesFromProps, GraphQLBase } from './hoc-utils'; -import { OperationOption, OptionProps, MutateProps } from './types'; -import { ApolloCache } from '../../core'; +import type { OperationOption, OptionProps, MutateProps } from './types'; +import type { ApolloCache } from '../../core'; export function withMutation< TProps extends TGraphQLVariables | {} = {}, diff --git a/src/react/hoc/query-hoc.tsx b/src/react/hoc/query-hoc.tsx index a16acb65429..ab8980a4fe3 100644 --- a/src/react/hoc/query-hoc.tsx +++ b/src/react/hoc/query-hoc.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { parser } from '../parser'; -import { BaseQueryOptions } from '../types/types'; +import type { BaseQueryOptions } from '../types/types'; import { Query } from '../components'; import { getDisplayName, @@ -12,7 +12,7 @@ import { defaultMapPropsToOptions, defaultMapPropsToSkip } from './hoc-utils'; -import { OperationOption, OptionProps, DataProps } from './types'; +import type { OperationOption, OptionProps, DataProps } from './types'; export function withQuery< TProps extends TGraphQLVariables | Record = Record, diff --git a/src/react/hoc/subscription-hoc.tsx b/src/react/hoc/subscription-hoc.tsx index 2a83c8043ea..876ae389709 100644 --- a/src/react/hoc/subscription-hoc.tsx +++ b/src/react/hoc/subscription-hoc.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { parser } from '../parser'; -import { BaseQueryOptions } from '../types/types'; +import type { BaseQueryOptions } from '../types/types'; import { Subscription } from '../components'; import { getDisplayName, @@ -12,7 +12,7 @@ import { defaultMapPropsToOptions, defaultMapPropsToSkip } from './hoc-utils'; -import { OperationOption, OptionProps, DataProps } from './types'; +import type { OperationOption, OptionProps, DataProps } from './types'; export function withSubscription< TProps extends TGraphQLVariables | {} = {}, diff --git a/src/react/hoc/types.ts b/src/react/hoc/types.ts index bb09cee252a..11cfcbf88db 100644 --- a/src/react/hoc/types.ts +++ b/src/react/hoc/types.ts @@ -1,6 +1,6 @@ -import { ApolloCache, ApolloClient } from '../../core'; -import { ApolloError } from '../../errors'; -import { +import type { ApolloCache, ApolloClient } from '../../core'; +import type { ApolloError } from '../../errors'; +import type { ApolloQueryResult, OperationVariables, FetchMoreOptions, @@ -9,7 +9,7 @@ import { SubscribeToMoreOptions, DefaultContext, } from '../../core'; -import { +import type { MutationFunction, BaseQueryOptions, BaseMutationOptions, diff --git a/src/react/hoc/withApollo.tsx b/src/react/hoc/withApollo.tsx index d27dfcb1bf9..ba457495352 100644 --- a/src/react/hoc/withApollo.tsx +++ b/src/react/hoc/withApollo.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { ApolloConsumer } from '../context'; -import { OperationOption, WithApolloClient } from './types'; +import type { OperationOption, WithApolloClient } from './types'; function getDisplayName

(WrappedComponent: React.ComponentType

) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; diff --git a/src/react/hooks/internal/useDeepMemo.ts b/src/react/hooks/internal/useDeepMemo.ts index 61d4dd99e7b..5f9c3cb2351 100644 --- a/src/react/hooks/internal/useDeepMemo.ts +++ b/src/react/hooks/internal/useDeepMemo.ts @@ -1,4 +1,5 @@ -import { useRef, DependencyList } from 'react'; +import type { DependencyList } from 'react'; +import { useRef } from 'react'; import { equal } from '@wry/equality'; export function useDeepMemo( diff --git a/src/react/hooks/useApolloClient.ts b/src/react/hooks/useApolloClient.ts index 02c403be2fe..61a7adf8d16 100644 --- a/src/react/hooks/useApolloClient.ts +++ b/src/react/hooks/useApolloClient.ts @@ -1,6 +1,6 @@ import { invariant } from '../../utilities/globals'; import { useContext } from 'react'; -import { ApolloClient } from '../../core'; +import type { ApolloClient } from '../../core'; import { getApolloContext } from '../context'; export function useApolloClient( diff --git a/src/react/hooks/useFragment.ts b/src/react/hooks/useFragment.ts index 4935331c457..a0f1fa45fcd 100644 --- a/src/react/hooks/useFragment.ts +++ b/src/react/hooks/useFragment.ts @@ -1,8 +1,9 @@ import { useRef } from "react"; import { equal } from "@wry/equality"; -import { DeepPartial, mergeDeepArray } from "../../utilities"; -import { +import type { DeepPartial} from "../../utilities"; +import { mergeDeepArray } from "../../utilities"; +import type { Cache, Reference, StoreObject, @@ -11,8 +12,8 @@ import { import { useApolloClient } from "./useApolloClient"; import { useSyncExternalStore } from "./useSyncExternalStore"; -import { OperationVariables } from "../../core"; -import { NoInfer } from "../types/types"; +import type { OperationVariables } from "../../core"; +import type { NoInfer } from "../types/types"; export interface UseFragmentOptions extends Omit< diff --git a/src/react/hooks/useLazyQuery.ts b/src/react/hooks/useLazyQuery.ts index 0819eefeb4b..20b82558702 100644 --- a/src/react/hooks/useLazyQuery.ts +++ b/src/react/hooks/useLazyQuery.ts @@ -1,10 +1,10 @@ -import { DocumentNode } from 'graphql'; -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { DocumentNode } from 'graphql'; +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; import { useCallback, useMemo, useRef } from 'react'; -import { OperationVariables } from '../../core'; +import type { OperationVariables } from '../../core'; import { mergeOptions } from '../../utilities'; -import { +import type { LazyQueryHookExecOptions, LazyQueryHookOptions, LazyQueryResultTuple, diff --git a/src/react/hooks/useMutation.ts b/src/react/hooks/useMutation.ts index 9de8a628ec9..7883d8c3ebd 100644 --- a/src/react/hooks/useMutation.ts +++ b/src/react/hooks/useMutation.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; -import { DocumentNode } from 'graphql'; -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; -import { +import type { DocumentNode } from 'graphql'; +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { MutationFunctionOptions, MutationHookOptions, MutationResult, @@ -9,11 +9,12 @@ import { NoInfer, } from '../types/types'; -import { +import type { ApolloCache, DefaultContext, - mergeOptions, - OperationVariables, + OperationVariables} from '../../core'; +import { + mergeOptions } from '../../core'; import { equal } from '@wry/equality'; import { DocumentType, verifyDocumentType } from '../parser'; diff --git a/src/react/hooks/useQuery.ts b/src/react/hooks/useQuery.ts index cf96685fbeb..35957e046f8 100644 --- a/src/react/hooks/useQuery.ts +++ b/src/react/hooks/useQuery.ts @@ -10,19 +10,22 @@ import { import { useSyncExternalStore } from './useSyncExternalStore'; import { equal } from '@wry/equality'; -import { mergeOptions, OperationVariables, WatchQueryFetchPolicy } from '../../core'; -import { ApolloContextValue, getApolloContext } from '../context'; +import type { OperationVariables, WatchQueryFetchPolicy } from '../../core'; +import { mergeOptions } from '../../core'; +import type { ApolloContextValue} from '../context'; +import { getApolloContext } from '../context'; import { ApolloError } from '../../errors'; -import { +import type { ApolloClient, ApolloQueryResult, - NetworkStatus, ObservableQuery, DocumentNode, TypedDocumentNode, - WatchQueryOptions, -} from '../../core'; + WatchQueryOptions} from '../../core'; import { + NetworkStatus +} from '../../core'; +import type { QueryHookOptions, QueryResult, ObservableQueryFields, diff --git a/src/react/hooks/useReactiveVar.ts b/src/react/hooks/useReactiveVar.ts index 7c88a84c453..b9b96090ab5 100644 --- a/src/react/hooks/useReactiveVar.ts +++ b/src/react/hooks/useReactiveVar.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { ReactiveVar } from '../../core'; +import type { ReactiveVar } from '../../core'; export function useReactiveVar(rv: ReactiveVar): T { const value = rv(); diff --git a/src/react/hooks/useSubscription.ts b/src/react/hooks/useSubscription.ts index 5fc0fdaa590..5da11a014ae 100644 --- a/src/react/hooks/useSubscription.ts +++ b/src/react/hooks/useSubscription.ts @@ -1,16 +1,16 @@ import { invariant } from '../../utilities/globals'; import { useState, useRef, useEffect } from 'react'; -import { DocumentNode } from 'graphql'; -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { DocumentNode } from 'graphql'; +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; import { equal } from '@wry/equality'; import { DocumentType, verifyDocumentType } from '../parser'; -import { +import type { NoInfer, SubscriptionHookOptions, SubscriptionResult } from '../types/types'; -import { OperationVariables } from '../../core'; +import type { OperationVariables } from '../../core'; import { useApolloClient } from './useApolloClient'; export function useSubscription( diff --git a/src/react/hooks/useSuspenseCache.ts b/src/react/hooks/useSuspenseCache.ts index f35773acf63..5dd01c18df3 100644 --- a/src/react/hooks/useSuspenseCache.ts +++ b/src/react/hooks/useSuspenseCache.ts @@ -1,7 +1,7 @@ import { useContext } from 'react'; import { getApolloContext } from '../context'; import { invariant } from '../../utilities/globals'; -import { SuspenseCache } from '../cache'; +import type { SuspenseCache } from '../cache'; export function useSuspenseCache(override?: SuspenseCache) { const context = useContext(getApolloContext()); diff --git a/src/react/hooks/useSuspenseQuery.ts b/src/react/hooks/useSuspenseQuery.ts index 0e19a6f6565..406167e6af1 100644 --- a/src/react/hooks/useSuspenseQuery.ts +++ b/src/react/hooks/useSuspenseQuery.ts @@ -1,8 +1,7 @@ import { invariant, __DEV__ } from '../../utilities/globals'; import { useRef, useCallback, useMemo, useEffect, useState } from 'react'; -import { +import type { ApolloClient, - ApolloError, ApolloQueryResult, DocumentNode, OperationVariables, @@ -10,19 +9,22 @@ import { WatchQueryOptions, WatchQueryFetchPolicy, NetworkStatus, - FetchMoreQueryOptions, + FetchMoreQueryOptions} from '../../core'; +import { + ApolloError } from '../../core'; -import { DeepPartial, isNonEmptyArray } from '../../utilities'; +import type { DeepPartial} from '../../utilities'; +import { isNonEmptyArray } from '../../utilities'; import { useApolloClient } from './useApolloClient'; import { DocumentType, verifyDocumentType } from '../parser'; -import { +import type { SuspenseQueryHookOptions, ObservableQueryFields, NoInfer, } from '../types/types'; import { useDeepMemo, useStrictModeSafeCleanupEffect, __use } from './internal'; import { useSuspenseCache } from './useSuspenseCache'; -import { QuerySubscription } from '../cache/QuerySubscription'; +import type { QuerySubscription } from '../cache/QuerySubscription'; import { canonicalStringify } from '../../cache'; export interface UseSuspenseQueryResult< diff --git a/src/react/parser/index.ts b/src/react/parser/index.ts index ad1c401908e..a9417e242bc 100644 --- a/src/react/parser/index.ts +++ b/src/react/parser/index.ts @@ -1,6 +1,6 @@ import { invariant } from '../../utilities/globals'; -import { +import type { DocumentNode, DefinitionNode, VariableDefinitionNode, diff --git a/src/react/ssr/RenderPromises.ts b/src/react/ssr/RenderPromises.ts index 204c755d18b..a511f96c0b8 100644 --- a/src/react/ssr/RenderPromises.ts +++ b/src/react/ssr/RenderPromises.ts @@ -1,7 +1,7 @@ -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; -import { ObservableQuery, OperationVariables } from '../../core'; -import { QueryDataOptions } from '../types/types'; +import type { ObservableQuery, OperationVariables } from '../../core'; +import type { QueryDataOptions } from '../types/types'; // TODO: A vestigial interface from when hooks were implemented with utility // classes, which should be deleted in the future. diff --git a/src/react/ssr/renderToStringWithData.ts b/src/react/ssr/renderToStringWithData.ts index 3fecc1ef27b..a086907d726 100644 --- a/src/react/ssr/renderToStringWithData.ts +++ b/src/react/ssr/renderToStringWithData.ts @@ -1,4 +1,4 @@ -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { getMarkupFromTree } from './getDataFromTree'; import { renderToString } from 'react-dom/server'; diff --git a/src/react/types/types.ts b/src/react/types/types.ts index f7b5a4ce240..64d0a6b9b7d 100644 --- a/src/react/types/types.ts +++ b/src/react/types/types.ts @@ -1,11 +1,11 @@ -import { ReactNode } from 'react'; -import { DocumentNode } from 'graphql'; -import { TypedDocumentNode } from '@graphql-typed-document-node/core'; - -import { Observable, ObservableSubscription } from '../../utilities'; -import { FetchResult } from '../../link/core'; -import { ApolloError } from '../../errors'; -import { +import type { ReactNode } from 'react'; +import type { DocumentNode } from 'graphql'; +import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; + +import type { Observable, ObservableSubscription } from '../../utilities'; +import type { FetchResult } from '../../link/core'; +import type { ApolloError } from '../../errors'; +import type { ApolloCache, ApolloClient, DefaultContext, @@ -18,7 +18,7 @@ import { WatchQueryOptions, WatchQueryFetchPolicy, } from '../../core'; -import { SuspenseCache } from '../cache'; +import type { SuspenseCache } from '../cache'; /* Common types */ diff --git a/src/testing/core/mocking/mockClient.ts b/src/testing/core/mocking/mockClient.ts index f68d719b898..d45c7293dc7 100644 --- a/src/testing/core/mocking/mockClient.ts +++ b/src/testing/core/mocking/mockClient.ts @@ -1,7 +1,8 @@ -import { DocumentNode } from 'graphql'; +import type { DocumentNode } from 'graphql'; import { ApolloClient } from '../../../core'; -import { InMemoryCache, NormalizedCacheObject } from '../../../cache'; +import type { NormalizedCacheObject } from '../../../cache'; +import { InMemoryCache } from '../../../cache'; import { mockSingleLink } from './mockLink'; export function createMockClient( diff --git a/src/testing/core/mocking/mockLink.ts b/src/testing/core/mocking/mockLink.ts index ed392eff702..0fa2fc276b6 100644 --- a/src/testing/core/mocking/mockLink.ts +++ b/src/testing/core/mocking/mockLink.ts @@ -3,11 +3,12 @@ import { invariant } from '../../../utilities/globals'; import { print } from 'graphql'; import { equal } from '@wry/equality'; -import { - ApolloLink, +import type { Operation, GraphQLRequest, - FetchResult, + FetchResult} from '../../../link/core'; +import { + ApolloLink } from '../../../link/core'; import { diff --git a/src/testing/core/mocking/mockQueryManager.ts b/src/testing/core/mocking/mockQueryManager.ts index 11d63b03fa8..760214d1e84 100644 --- a/src/testing/core/mocking/mockQueryManager.ts +++ b/src/testing/core/mocking/mockQueryManager.ts @@ -1,5 +1,6 @@ import { QueryManager } from '../../../core/QueryManager'; -import { mockSingleLink, MockedResponse } from './mockLink'; +import type { MockedResponse } from './mockLink'; +import { mockSingleLink } from './mockLink'; import { InMemoryCache } from '../../../cache'; // Helper method for the tests that construct a query manager out of a diff --git a/src/testing/core/mocking/mockSubscriptionLink.ts b/src/testing/core/mocking/mockSubscriptionLink.ts index 664789a3ea6..8c92bb35a22 100644 --- a/src/testing/core/mocking/mockSubscriptionLink.ts +++ b/src/testing/core/mocking/mockSubscriptionLink.ts @@ -1,5 +1,6 @@ import { Observable } from '../../../utilities'; -import { ApolloLink, FetchResult, Operation } from '../../../link/core'; +import type { FetchResult, Operation } from '../../../link/core'; +import { ApolloLink } from '../../../link/core'; export interface MockedSubscription { request: Operation; diff --git a/src/testing/core/mocking/mockWatchQuery.ts b/src/testing/core/mocking/mockWatchQuery.ts index 51617a06b12..29bbb559a99 100644 --- a/src/testing/core/mocking/mockWatchQuery.ts +++ b/src/testing/core/mocking/mockWatchQuery.ts @@ -1,6 +1,6 @@ -import { MockedResponse } from './mockLink'; +import type { MockedResponse } from './mockLink'; import mockQueryManager from './mockQueryManager'; -import { ObservableQuery } from '../../../core'; +import type { ObservableQuery } from '../../../core'; export default (...mockedResponses: MockedResponse[]): ObservableQuery => { const queryManager = mockQueryManager(...mockedResponses); diff --git a/src/testing/core/observableToPromise.ts b/src/testing/core/observableToPromise.ts index c9aeff54c57..007d5b5ddf8 100644 --- a/src/testing/core/observableToPromise.ts +++ b/src/testing/core/observableToPromise.ts @@ -1,5 +1,5 @@ -import { ObservableQuery, ApolloQueryResult } from '../../core'; -import { ObservableSubscription } from '../../utilities'; +import type { ObservableQuery, ApolloQueryResult } from '../../core'; +import type { ObservableSubscription } from '../../utilities'; /** * diff --git a/src/testing/core/subscribeAndCount.ts b/src/testing/core/subscribeAndCount.ts index a80f4ebe94c..c734c466f1a 100644 --- a/src/testing/core/subscribeAndCount.ts +++ b/src/testing/core/subscribeAndCount.ts @@ -1,4 +1,5 @@ -import { ObservableSubscription, asyncMap, Observable } from '../../utilities'; +import type { ObservableSubscription, Observable } from '../../utilities'; +import { asyncMap } from '../../utilities'; export default function subscribeAndCount( reject: (reason: any) => any, diff --git a/src/testing/react/MockedProvider.tsx b/src/testing/react/MockedProvider.tsx index 096576d11fa..e634be12057 100644 --- a/src/testing/react/MockedProvider.tsx +++ b/src/testing/react/MockedProvider.tsx @@ -1,13 +1,15 @@ import * as React from 'react'; -import { ApolloClient, DefaultOptions } from '../../core'; +import type { DefaultOptions } from '../../core'; +import { ApolloClient } from '../../core'; import { InMemoryCache as Cache } from '../../cache'; import { ApolloProvider } from '../../react/context'; import { SuspenseCache } from '../../react'; -import { MockLink, MockedResponse } from '../core'; -import { ApolloLink } from '../../link/core'; -import { Resolvers } from '../../core'; -import { ApolloCache } from '../../cache'; +import type { MockedResponse } from '../core'; +import { MockLink } from '../core'; +import type { ApolloLink } from '../../link/core'; +import type { Resolvers } from '../../core'; +import type { ApolloCache } from '../../cache'; export interface MockedProviderProps { mocks?: ReadonlyArray; diff --git a/src/utilities/common/compact.ts b/src/utilities/common/compact.ts index 912d8e30377..cdab8d83b35 100644 --- a/src/utilities/common/compact.ts +++ b/src/utilities/common/compact.ts @@ -1,4 +1,4 @@ -import { TupleToIntersection } from './mergeDeep'; +import type { TupleToIntersection } from './mergeDeep'; /** * Merges the provided objects shallowly and removes diff --git a/src/utilities/common/errorHandling.ts b/src/utilities/common/errorHandling.ts index b2c7eb68dc2..e7fa5216f4e 100644 --- a/src/utilities/common/errorHandling.ts +++ b/src/utilities/common/errorHandling.ts @@ -1,4 +1,4 @@ -import { FetchResult } from "../../link/core"; +import type { FetchResult } from "../../link/core"; import { isNonEmptyArray } from "../../utilities/common/arrays"; import { isExecutionPatchIncrementalResult } from "../../utilities/common/incrementalResult"; diff --git a/src/utilities/common/incrementalResult.ts b/src/utilities/common/incrementalResult.ts index fcc8ae47b2b..53a628678c0 100644 --- a/src/utilities/common/incrementalResult.ts +++ b/src/utilities/common/incrementalResult.ts @@ -1,4 +1,4 @@ -import { +import type { ExecutionPatchIncrementalResult, ExecutionPatchInitialResult, ExecutionPatchResult, diff --git a/src/utilities/common/omitDeep.ts b/src/utilities/common/omitDeep.ts index 64d5eb0e04a..7994375a85f 100644 --- a/src/utilities/common/omitDeep.ts +++ b/src/utilities/common/omitDeep.ts @@ -1,4 +1,4 @@ -import { DeepOmit } from '../types/DeepOmit'; +import type { DeepOmit } from '../types/DeepOmit'; import { isPlainObject } from './objects'; export function omitDeep(value: T, key: K) { diff --git a/src/utilities/common/responseIterator.ts b/src/utilities/common/responseIterator.ts index 99a02096b94..4b316563e05 100644 --- a/src/utilities/common/responseIterator.ts +++ b/src/utilities/common/responseIterator.ts @@ -1,5 +1,5 @@ -import { Response as NodeResponse } from "node-fetch"; -import { Readable as NodeReadableStream } from "stream"; +import type { Response as NodeResponse } from "node-fetch"; +import type { Readable as NodeReadableStream } from "stream"; import { canUseAsyncIteratorSymbol } from "./canUse"; export function isNodeResponse(value: any): value is NodeResponse { diff --git a/src/utilities/graphql/directives.ts b/src/utilities/graphql/directives.ts index 07eb5e0f15b..9072e54aa73 100644 --- a/src/utilities/graphql/directives.ts +++ b/src/utilities/graphql/directives.ts @@ -2,7 +2,7 @@ import { invariant } from '../globals'; // Provides the methods that allow QueryManager to handle the `skip` and // `include` directives within GraphQL. -import { +import type { SelectionNode, VariableNode, BooleanValueNode, @@ -10,7 +10,8 @@ import { DocumentNode, ArgumentNode, ValueNode, - ASTNode, + ASTNode} from 'graphql'; +import { visit, BREAK, } from 'graphql'; diff --git a/src/utilities/graphql/fragments.ts b/src/utilities/graphql/fragments.ts index 0746f6b7b20..cab54b25873 100644 --- a/src/utilities/graphql/fragments.ts +++ b/src/utilities/graphql/fragments.ts @@ -1,6 +1,6 @@ import { invariant, InvariantError } from '../globals'; -import { +import type { DocumentNode, FragmentDefinitionNode, InlineFragmentNode, diff --git a/src/utilities/graphql/getFromAST.ts b/src/utilities/graphql/getFromAST.ts index 0f04204311a..57ef45428bb 100644 --- a/src/utilities/graphql/getFromAST.ts +++ b/src/utilities/graphql/getFromAST.ts @@ -1,6 +1,6 @@ import { invariant, InvariantError } from '../globals'; -import { +import type { DocumentNode, OperationDefinitionNode, FragmentDefinitionNode, diff --git a/src/utilities/graphql/storeUtils.ts b/src/utilities/graphql/storeUtils.ts index 7e7c7c6d257..9d40d0d49b6 100644 --- a/src/utilities/graphql/storeUtils.ts +++ b/src/utilities/graphql/storeUtils.ts @@ -1,6 +1,6 @@ import { InvariantError } from '../globals'; -import { +import type { DirectiveNode, FieldNode, IntValueNode, @@ -21,7 +21,8 @@ import { } from 'graphql'; import { isNonNullObject } from '../common/objects'; -import { FragmentMap, getFragmentFromSelection } from './fragments'; +import type { FragmentMap} from './fragments'; +import { getFragmentFromSelection } from './fragments'; export interface Reference { readonly __ref: string; diff --git a/src/utilities/graphql/transform.ts b/src/utilities/graphql/transform.ts index d906320e975..8e255398ff0 100644 --- a/src/utilities/graphql/transform.ts +++ b/src/utilities/graphql/transform.ts @@ -1,6 +1,6 @@ import { invariant } from '../globals'; -import { +import type { DocumentNode, SelectionNode, SelectionSetNode, @@ -11,11 +11,12 @@ import { ArgumentNode, FragmentSpreadNode, VariableDefinitionNode, - visit, ASTNode, - Kind, ASTVisitor, - InlineFragmentNode, + InlineFragmentNode} from 'graphql'; +import { + visit, + Kind } from 'graphql'; import { @@ -26,9 +27,10 @@ import { getMainDefinition, } from './getFromAST'; import { isField } from './storeUtils'; +import type { + FragmentMap} from './fragments'; import { - createFragmentMap, - FragmentMap, + createFragmentMap } from './fragments'; import { isArray, isNonEmptyArray } from '../common/arrays'; diff --git a/src/utilities/observables/Concast.ts b/src/utilities/observables/Concast.ts index deff3ce1730..2b709e2ec72 100644 --- a/src/utilities/observables/Concast.ts +++ b/src/utilities/observables/Concast.ts @@ -1,4 +1,5 @@ -import { Observable, Observer, ObservableSubscription, Subscriber } from "./Observable"; +import type { Observer, ObservableSubscription, Subscriber } from "./Observable"; +import { Observable } from "./Observable"; import { iterateObserversSafely } from "./iteration"; import { fixObservableSubclass } from "./subclassing"; diff --git a/src/utilities/observables/Observable.ts b/src/utilities/observables/Observable.ts index 94afb6a587a..a789ef478e8 100644 --- a/src/utilities/observables/Observable.ts +++ b/src/utilities/observables/Observable.ts @@ -1,8 +1,9 @@ -import { - Observable, +import type { Observer, Subscription as ObservableSubscription, - Subscriber, + Subscriber} from 'zen-observable-ts'; +import { + Observable } from 'zen-observable-ts'; // This simplified polyfill attempts to follow the ECMAScript Observable diff --git a/src/utilities/observables/asyncMap.ts b/src/utilities/observables/asyncMap.ts index 2f790dc1516..247cbadd903 100644 --- a/src/utilities/observables/asyncMap.ts +++ b/src/utilities/observables/asyncMap.ts @@ -1,4 +1,5 @@ -import { Observable, Observer } from "./Observable"; +import type { Observer } from "./Observable"; +import { Observable } from "./Observable"; // Like Observable.prototype.map, except that the mapping function can // optionally return a Promise (or be async). diff --git a/src/utilities/observables/iteration.ts b/src/utilities/observables/iteration.ts index 04dbcc0ac4b..e5c8c013feb 100644 --- a/src/utilities/observables/iteration.ts +++ b/src/utilities/observables/iteration.ts @@ -1,4 +1,4 @@ -import { Observer } from "./Observable"; +import type { Observer } from "./Observable"; export function iterateObserversSafely( observers: Set>, diff --git a/src/utilities/policies/pagination.ts b/src/utilities/policies/pagination.ts index 163b1631601..ba17d5d5daf 100644 --- a/src/utilities/policies/pagination.ts +++ b/src/utilities/policies/pagination.ts @@ -1,6 +1,6 @@ import { __rest } from "tslib"; -import { FieldPolicy, Reference } from '../../cache'; +import type { FieldPolicy, Reference } from '../../cache'; import { mergeDeep } from '../common/mergeDeep'; type KeyArgs = FieldPolicy["keyArgs"]; diff --git a/src/utilities/types/DeepOmit.ts b/src/utilities/types/DeepOmit.ts index 0b720e3b9e3..6917250f55b 100644 --- a/src/utilities/types/DeepOmit.ts +++ b/src/utilities/types/DeepOmit.ts @@ -1,4 +1,4 @@ -import { Primitive } from './Primitive'; +import type { Primitive } from './Primitive'; // DeepOmit primitives include functions since these are unmodified. type DeepOmitPrimitive = Primitive | Function; diff --git a/src/utilities/types/DeepPartial.ts b/src/utilities/types/DeepPartial.ts index 7fb0a5425a7..e9d1848e9e2 100644 --- a/src/utilities/types/DeepPartial.ts +++ b/src/utilities/types/DeepPartial.ts @@ -14,7 +14,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { Primitive } from './Primitive'; +import type { Primitive } from './Primitive'; type DeepPartialPrimitive = Primitive | Date | RegExp;