diff --git a/.api-reports/api-report-testing_internal.api.md b/.api-reports/api-report-testing_internal.api.md new file mode 100644 index 00000000000..82ebd8ea64c --- /dev/null +++ b/.api-reports/api-report-testing_internal.api.md @@ -0,0 +1,278 @@ +## API Report File for "@apollo/client" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { ApolloClient } from '@apollo/client/core'; +import { ApolloLink } from '@apollo/client/core'; +import type { ApolloPayloadResult } from '@apollo/client/core'; +import { FetchResult } from '@apollo/client/core'; +import type { GraphQLFormattedError } from 'graphql-17-alpha2'; +import { GraphQLRequest } from '@apollo/client/core'; +import { HttpLink } from '@apollo/client/link/http'; +import type { InitialIncrementalExecutionResult } from 'graphql-17-alpha2'; +import type { MaskedDocumentNode } from '@apollo/client/masking'; +import type { MockedProviderProps } from '@apollo/client/testing/react'; +import type { MockedResponse } from '@apollo/client/testing/core'; +import type { Observable } from 'rxjs'; +import type { Queries } from '@testing-library/dom'; +import type { queries } from '@testing-library/dom'; +import * as React_2 from 'react'; +import type * as ReactDOMClient from 'react-dom/client'; +import type { RenderHookOptions } from '@testing-library/react'; +import type { RenderHookResult } from '@testing-library/react'; +import type { RenderOptions } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { ResultFunction } from '@apollo/client/testing/core'; +import type { Subscribable } from 'rxjs'; +import type { SubsequentIncrementalExecutionResult } from 'graphql-17-alpha2'; +import type { TypedDocumentNode } from '@apollo/client/core'; + +// @public (undocumented) +export function actAsync(scope: () => T | Promise): Promise; + +// @public (undocumented) +export function addDelayToMocks[]>(mocks: T, delay?: number, override?: boolean): { + delay: number; + request: GraphQLRequest>; + maxUsageCount?: number; + result?: FetchResult | ResultFunction, Record> | undefined; + error?: Error; + variableMatcher?: ((arg: Record) => boolean) | undefined; + newData?: ResultFunction, Record> | undefined; +}[]; + +// @public (undocumented) +type ConsoleMethod = "log" | "info" | "warn" | "error" | "debug"; + +// @public (undocumented) +export function createClientWrapper(client: ApolloClient, Wrapper?: React_2.JSXElementConstructor<{ + children: React_2.ReactNode; +}>): React_2.JSXElementConstructor<{ + children: React_2.ReactNode; +}>; + +// @public (undocumented) +export function createMockWrapper(renderOptions: MockedProviderProps, Wrapper?: React_2.JSXElementConstructor<{ + children: React_2.ReactNode; +}>): React_2.JSXElementConstructor<{ + children: React_2.ReactNode; +}>; + +// @public (undocumented) +export function enableFakeTimers(config?: FakeTimersConfig | LegacyFakeTimersConfig): Disposable; + +// @public (undocumented) +type HydrateableContainer = Parameters<(typeof ReactDOMClient)["hydrateRoot"]>[0]; + +// @public (undocumented) +type HydrateableContainer_2 = Parameters<(typeof ReactDOMClient)["hydrateRoot"]>[0]; + +// @public (undocumented) +interface Letter { + // (undocumented) + __typename: "Letter"; + // (undocumented) + letter: string; + // (undocumented) + position: number; +} + +// @public (undocumented) +export interface MaskedVariablesCaseData { + // (undocumented) + character: { + __typename: "Character"; + id: string; + } & { + " $fragmentRefs"?: { + MaskedVariablesCaseFragment: MaskedVariablesCaseFragment; + }; + }; +} + +// @public (undocumented) +type MaskedVariablesCaseFragment = { + __typename: "Character"; + name: string; +} & { + " $fragmentName"?: "MaskedVariablesCaseFragment"; +}; + +// @public (undocumented) +export function mockDeferStream, TExtensions = Record>(): { + httpLink: HttpLink; + enqueueInitialChunk(chunk: InitialIncrementalExecutionResult): void; + enqueueSubsequentChunk(chunk: SubsequentIncrementalExecutionResult): void; + enqueueErrorChunk(errors: GraphQLFormattedError[]): void; +}; + +// @public (undocumented) +export function mockMultipartSubscriptionStream, TExtensions = Record>(): { + httpLink: HttpLink; + enqueueHeartbeat: () => void; + enqueuePayloadResult(payload: ApolloPayloadResult["payload"], hasNext?: boolean): void; + enqueueProtocolErrors(errors: ApolloPayloadResult["errors"]): void; +}; + +// @public (undocumented) +type ObservableEvent = { + type: "next"; + value: T; +} | { + type: "error"; + error: any; +} | { + type: "complete"; +}; + +// @public (undocumented) +export class ObservableStream { + constructor(observable: Observable | Subscribable); + // Warning: (ae-forgotten-export) The symbol "TakeOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "ObservableEvent" needs to be exported by the entry point index.d.ts + // + // (undocumented) + peek({ timeout }?: TakeOptions): Promise>; + // (undocumented) + take({ timeout }?: TakeOptions): Promise>; + // (undocumented) + takeComplete(options?: TakeOptions): Promise; + // (undocumented) + takeError(options?: TakeOptions): Promise; + // (undocumented) + takeNext(options?: TakeOptions): Promise; + // (undocumented) + unsubscribe(): void; +} + +// @public (undocumented) +export interface PaginatedCaseData { + // Warning: (ae-forgotten-export) The symbol "Letter" needs to be exported by the entry point index.d.ts + // + // (undocumented) + letters: Letter[]; +} + +// @public (undocumented) +export interface PaginatedCaseVariables { + // (undocumented) + limit?: number; + // (undocumented) + offset?: number; +} + +// Warning: (ae-forgotten-export) The symbol "RendererableContainer" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "HydrateableContainer" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export function renderAsync(ui: React.ReactNode, options: RenderOptions): Promise>; + +// @public (undocumented) +export function renderAsync(ui: React.ReactNode, options?: Omit | undefined): Promise; + +// @public (undocumented) +type RendererableContainer = ReactDOMClient.Container; + +// @public (undocumented) +type RendererableContainer_2 = ReactDOMClient.Container; + +// Warning: (ae-forgotten-export) The symbol "RendererableContainer_2" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "HydrateableContainer_2" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export function renderHookAsync(renderCallback: (initialProps: Props) => Result, options?: RenderHookOptions | undefined): Promise>; + +// @public +export function resetApolloContext(): void; + +// @public (undocumented) +export function setupMaskedVariablesCase(): { + mocks: MockedResponse>[]; + query: MaskedDocumentNode; + unmaskedQuery: TypedDocumentNode; +}; + +// @public (undocumented) +export function setupPaginatedCase(): { + query: TypedDocumentNode; + link: ApolloLink; + data: { + __typename: string; + letter: string; + position: number; + }[]; +}; + +// @public (undocumented) +export function setupSimpleCase(): { + query: TypedDocumentNode>; + mocks: MockedResponse>[]; +}; + +// @public (undocumented) +export function setupVariablesCase(): { + mocks: MockedResponse>[]; + query: TypedDocumentNode; +}; + +// @public (undocumented) +export interface SimpleCaseData { + // (undocumented) + greeting: string; +} + +// Warning: (ae-forgotten-export) The symbol "ConsoleMethod" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type Spies = Record>; + +// Warning: (ae-forgotten-export) The symbol "Spies" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export function spyOnConsole(...spyOn: Keys): Spies & Disposable; + +// @public (undocumented) +export namespace spyOnConsole { + var // (undocumented) + takeSnapshots: (...spyOn: Keys) => Spies & Disposable; +} + +// @public (undocumented) +interface TakeOptions { + // (undocumented) + timeout?: number; +} + +// @public (undocumented) +export interface VariablesCaseData { + // (undocumented) + character: { + __typename: "Character"; + id: string; + name: string; + }; +} + +// @public (undocumented) +export interface VariablesCaseVariables { + // (undocumented) + id: string; +} + +// @internal (undocumented) +export function withCleanup(item: T, cleanup: (item: T) => void): T & Disposable; + +// @public (undocumented) +export function withProdMode(): { + prevDEV: boolean; +} & Disposable; + +// Warnings were encountered during analysis: +// +// src/testing/internal/scenarios/index.ts:80:7 - (ae-forgotten-export) The symbol "MaskedVariablesCaseFragment" needs to be exported by the entry point index.d.ts + +// (No @packageDocumentation comment for this package) + +``` diff --git a/eslint-local-rules/import-from-export.ts b/eslint-local-rules/import-from-export.ts index 595f90a1561..b5b9bd861e6 100644 --- a/eslint-local-rules/import-from-export.ts +++ b/eslint-local-rules/import-from-export.ts @@ -265,3 +265,60 @@ export const noInternalImportOfficialExport = }, defaultOptions: [], }); + +/** + * to be used in tests, so the test imports from the library instead of testing internals + * (where possible) + */ +export const noRelativeImports = ESLintUtils.RuleCreator.withoutDocs({ + create(context, options) { + return { + ImportDeclaration(node) { + if (!node.source.value.startsWith("..")) { + // we're only interested in imports from parent folders outside of the test folder + return; + } + if (node.importKind === "type") { + // we're okay with internal types for now, although in most cases + // they should probably be exports if they are important enough + // that we need them for a test + return; + } + const resolvedTarget = resolve( + dirname(context.physicalFilename), + node.source.value + ); + if (options[0].ignoreFrom.includes(resolvedTarget)) { + return; + } + context.report({ + node: node.source, + messageId: "noRelativeImports", + }); + }, + }; + }, + meta: { + messages: { + noRelativeImports: + "Don't use relative imports in tests, import from official entry points instead.", + }, + type: "problem", + schema: [ + { + type: "object", + properties: { + ignoreFrom: { + type: "array", + items: { type: "string" }, + }, + }, + }, + ], + }, + defaultOptions: [ + { + ignoreFrom: [], + }, + ], +}); diff --git a/eslint-local-rules/index.mjs b/eslint-local-rules/index.mjs index 8955d4e6a08..0d5245dfbe1 100644 --- a/eslint-local-rules/index.mjs +++ b/eslint-local-rules/index.mjs @@ -4,6 +4,7 @@ import { importFromInsideOtherExport, noDuplicateExports, noInternalImportOfficialExport, + noRelativeImports, } from "./import-from-export.ts"; import { rule as requireDisableActEnvironment } from "./require-disable-act-environment.ts"; import { rule as requireUsingDisposable } from "./require-using-disposable.ts"; @@ -16,4 +17,5 @@ export default { "import-from-inside-other-export": importFromInsideOtherExport, "no-internal-import-official-export": noInternalImportOfficialExport, "no-duplicate-exports": noDuplicateExports, + "no-relative-imports": noRelativeImports, }; diff --git a/eslint.config.mjs b/eslint.config.mjs index 6fdc0c9ac37..e80d2e4fea5 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -72,6 +72,7 @@ export default [ }, }, + // rules for the whole repo rules: { "import/no-unresolved": "error", "import/order": [ @@ -107,6 +108,14 @@ export default [ }, ], "local-rules/no-duplicate-exports": "error", + "@typescript-eslint/consistent-type-imports": [ + "error", + { + prefer: "type-imports", + disallowTypeAnnotations: false, + fixStyle: "separate-type-imports", + }, + ], }, }, ...fixupConfigRules(compat.extends("plugin:react-hooks/recommended")).map( @@ -138,17 +147,9 @@ export default [ }, }, + // rules for source files, but no tests rules: { "react-compiler/react-compiler": "error", - "@typescript-eslint/consistent-type-imports": [ - "error", - { - prefer: "type-imports", - disallowTypeAnnotations: false, - fixStyle: "separate-type-imports", - }, - ], - "@typescript-eslint/consistent-type-exports": ["error"], "@typescript-eslint/no-import-type-side-effects": "error", @@ -215,6 +216,7 @@ export default [ }, }, + // rules for tests only rules: { "testing-library/prefer-user-event": "error", "testing-library/no-wait-for-multiple-assertions": "off", @@ -224,6 +226,7 @@ export default [ "local-rules/import-from-inside-other-export": "off", "local-rules/no-internal-import-official-export": runExtendedRules ? "error" : "off", + "local-rules/no-relative-imports": "error", "import/no-duplicates": "warn", "@typescript-eslint/no-floating-promises": "warn", }, diff --git a/package.json b/package.json index 19dd164a0bb..aff6fc00fe5 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "./testing/core": "./src/testing/core/index.ts", "./testing/experimental": "./src/testing/experimental/index.ts", "./testing/react": "./src/testing/react/index.ts", + "./testing/internal": "./src/testing/internal/index.ts", "./utilities": "./src/utilities/index.ts", "./utilities/internal": { "production": "./src/utilities/internal/index.production.ts", diff --git a/src/__tests__/ApolloClient.ts b/src/__tests__/ApolloClient.ts index 6716327df30..ae1492cfb5a 100644 --- a/src/__tests__/ApolloClient.ts +++ b/src/__tests__/ApolloClient.ts @@ -1,29 +1,33 @@ -import { TypedDocumentNode } from "@graphql-typed-document-node/core"; +import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { expectTypeOf } from "expect-type"; import { Kind } from "graphql"; import { gql } from "graphql-tag"; import { Observable, of } from "rxjs"; import { createFragmentRegistry, InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, +import type { ApolloQueryResult, DefaultOptions, - makeReference, MutateResult, - NetworkStatus, ObservableQuery, QueryOptions, } from "@apollo/client/core"; +import { + ApolloClient, + makeReference, + NetworkStatus, +} from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import { HttpLink } from "@apollo/client/link/http"; -import { Masked } from "@apollo/client/masking"; +import type { Masked } from "@apollo/client/masking"; import { MockLink } from "@apollo/client/testing"; -import { DeepPartial } from "@apollo/client/utilities"; +import { + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; +import type { DeepPartial } from "@apollo/client/utilities"; import { invariant } from "@apollo/client/utilities/invariant"; -import { ObservableStream, spyOnConsole } from "../testing/internal/index.js"; - describe("ApolloClient", () => { describe("constructor", () => { let oldFetch: any; diff --git a/src/__tests__/__snapshots__/exports.ts.snap b/src/__tests__/__snapshots__/exports.ts.snap index f1806949851..a70879b2e68 100644 --- a/src/__tests__/__snapshots__/exports.ts.snap +++ b/src/__tests__/__snapshots__/exports.ts.snap @@ -390,6 +390,29 @@ Array [ ] `; +exports[`exports of public entry points @apollo/client/testing/internal 1`] = ` +Array [ + "ObservableStream", + "actAsync", + "addDelayToMocks", + "createClientWrapper", + "createMockWrapper", + "enableFakeTimers", + "mockDeferStream", + "mockMultipartSubscriptionStream", + "renderAsync", + "renderHookAsync", + "resetApolloContext", + "setupMaskedVariablesCase", + "setupPaginatedCase", + "setupSimpleCase", + "setupVariablesCase", + "spyOnConsole", + "withCleanup", + "withProdMode", +] +`; + exports[`exports of public entry points @apollo/client/testing/react 1`] = ` Array [ "MockedProvider", diff --git a/src/__tests__/client.ts b/src/__tests__/client.ts index 173095046ed..fc8a78b7aac 100644 --- a/src/__tests__/client.ts +++ b/src/__tests__/client.ts @@ -1,41 +1,44 @@ import { waitFor } from "@testing-library/react"; -import { +import type { DocumentNode, FormattedExecutionResult, - GraphQLError, GraphQLFormattedError, - Kind, - print, - visit, } from "graphql"; +import { GraphQLError, Kind, print, visit } from "graphql"; import { gql } from "graphql-tag"; import { assign, cloneDeep } from "lodash"; -import { Observable, of, Subscription } from "rxjs"; +import { Observable, of } from "rxjs"; +import type { Subscription } from "rxjs"; +import type { + NormalizedCacheObject, + PossibleTypesMap, +} from "@apollo/client/cache"; import { createFragmentRegistry, InMemoryCache, makeVar, - NormalizedCacheObject, - PossibleTypesMap, } from "@apollo/client/cache"; -import { - ApolloClient, +import type { ApolloQueryResult, FetchPolicy, - NetworkStatus, ObservableQuery, Operation, QueryOptions, TypedDocumentNode, WatchQueryFetchPolicy, } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { CombinedGraphQLErrors, UnconventionalError, } from "@apollo/client/errors"; import { ApolloLink } from "@apollo/client/link/core"; import { MockLink, mockSingleLink, wait } from "@apollo/client/testing"; +import { + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { DocumentTransform, offsetLimitPagination, @@ -43,8 +46,6 @@ import { } from "@apollo/client/utilities"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { ObservableStream, spyOnConsole } from "../testing/internal/index.js"; - describe("client", () => { it("can be loaded via require", () => { /* tslint:disable */ diff --git a/src/__tests__/dataMasking.ts b/src/__tests__/dataMasking.ts index 7790848159a..0f7a6c3504a 100644 --- a/src/__tests__/dataMasking.ts +++ b/src/__tests__/dataMasking.ts @@ -1,35 +1,36 @@ -import { FragmentSpreadNode, Kind, visit } from "graphql"; +import type { FragmentSpreadNode } from "graphql"; +import { Kind, visit } from "graphql"; import { of } from "rxjs"; import { createFragmentRegistry } from "@apollo/client/cache"; +import type { + Cache, + DataProxy, + FetchPolicy, + OperationVariables, + Reference, + TypedDocumentNode, +} from "@apollo/client/core"; import { ApolloCache, ApolloClient, ApolloLink, - Cache, - DataProxy, DocumentTransform, - FetchPolicy, gql, InMemoryCache, NetworkStatus, - OperationVariables, - Reference, - TypedDocumentNode, } from "@apollo/client/core"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; -import { MaskedDocumentNode, Unmasked } from "@apollo/client/masking"; +import type { MaskedDocumentNode, Unmasked } from "@apollo/client/masking"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink, wait } from "@apollo/client/testing"; import { - MockedResponse, - MockLink, - MockSubscriptionLink, - wait, -} from "@apollo/client/testing"; + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { isSubscriptionOperation } from "@apollo/client/utilities"; import { invariant } from "@apollo/client/utilities/invariant"; -import { ObservableStream, spyOnConsole } from "../testing/internal/index.js"; - const NO_CACHE_WARNING = '[%s]: Fragments masked by data masking are inaccessible when using fetch policy "no-cache". Please add `@unmask` to each fragment spread to access the data.'; diff --git a/src/__tests__/exports.ts b/src/__tests__/exports.ts index 34ea8f54f1d..4e8105f75bb 100644 --- a/src/__tests__/exports.ts +++ b/src/__tests__/exports.ts @@ -35,6 +35,7 @@ import * as reactSSR from "@apollo/client/react/ssr"; import * as testing from "@apollo/client/testing"; import * as testingCore from "@apollo/client/testing/core"; import * as testingExperimental from "@apollo/client/testing/experimental"; +import * as testingInternal from "@apollo/client/testing/internal"; import * as testingReact from "@apollo/client/testing/react"; import * as utilities from "@apollo/client/utilities"; import * as utilitiesEnvironment from "@apollo/client/utilities/environment"; @@ -42,6 +43,7 @@ import * as utilitiesGlobals from "@apollo/client/utilities/globals"; import * as utilitiesInternal from "@apollo/client/utilities/internal"; import * as utilitiesInvariant from "@apollo/client/utilities/invariant"; +// eslint-disable-next-line local-rules/no-relative-imports import { entryPoints } from "../../config/entryPoints.js"; type Namespace = object; @@ -96,6 +98,7 @@ describe("exports of public entry points", () => { check("@apollo/client/testing", testing); check("@apollo/client/testing/core", testingCore); check("@apollo/client/testing/experimental", testingExperimental); + check("@apollo/client/testing/internal", testingInternal); check("@apollo/client/testing/react", testingReact); check("@apollo/client/utilities", utilities); check("@apollo/client/utilities/internal", utilitiesInternal); diff --git a/src/__tests__/fetchMore.ts b/src/__tests__/fetchMore.ts index fc848f77f17..ce607f9ca0d 100644 --- a/src/__tests__/fetchMore.ts +++ b/src/__tests__/fetchMore.ts @@ -2,29 +2,25 @@ import { gql } from "graphql-tag"; import { assign, cloneDeep } from "lodash"; import { Observable } from "rxjs"; -import { +import type { ApolloCache, FieldMergeFunction, - InMemoryCache, InMemoryCacheConfig, } from "@apollo/client/cache"; +import { InMemoryCache } from "@apollo/client/cache"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { ApolloClient, ApolloLink, NetworkStatus } from "@apollo/client/core"; +import type { MockedResponse } from "@apollo/client/testing"; +import { mockSingleLink } from "@apollo/client/testing"; import { - ApolloClient, - ApolloLink, - NetworkStatus, - TypedDocumentNode, -} from "@apollo/client/core"; -import { MockedResponse, mockSingleLink } from "@apollo/client/testing"; + ObservableStream, + setupPaginatedCase, +} from "@apollo/client/testing/internal"; import { concatPagination, offsetLimitPagination, } from "@apollo/client/utilities"; -import { - ObservableStream, - setupPaginatedCase, -} from "../testing/internal/index.js"; - describe("updateQuery on a simple query", () => { const query = gql` query thing { diff --git a/src/__tests__/graphqlSubscriptions.ts b/src/__tests__/graphqlSubscriptions.ts index 8481393038b..0183698df04 100644 --- a/src/__tests__/graphqlSubscriptions.ts +++ b/src/__tests__/graphqlSubscriptions.ts @@ -7,12 +7,11 @@ import { CombinedProtocolErrors, } from "@apollo/client/errors"; import { MockSubscriptionLink } from "@apollo/client/testing"; - import { mockMultipartSubscriptionStream, ObservableStream, spyOnConsole, -} from "../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; describe("GraphQL Subscriptions", () => { const results = [ diff --git a/src/__tests__/local-state/export.ts b/src/__tests__/local-state/export.ts index 84be5ae0fcc..13d61ac5560 100644 --- a/src/__tests__/local-state/export.ts +++ b/src/__tests__/local-state/export.ts @@ -5,11 +5,10 @@ import { of } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; - import { ObservableStream, spyOnConsole, -} from "../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; describe("@client @export tests", () => { it("should not break @client only queries when the @export directive is used", async () => { diff --git a/src/__tests__/local-state/general.ts b/src/__tests__/local-state/general.ts index b89b00dc933..a0b2d1a4548 100644 --- a/src/__tests__/local-state/general.ts +++ b/src/__tests__/local-state/general.ts @@ -1,9 +1,8 @@ +import type { DocumentNode, GraphQLFormattedError } from "graphql"; import { - DocumentNode, getIntrospectionQuery, graphql, GraphQLError, - GraphQLFormattedError, GraphQLID, GraphQLInt, GraphQLObjectType, @@ -12,17 +11,19 @@ import { print, } from "graphql"; import { gql } from "graphql-tag"; -import { defer, Observable, of } from "rxjs"; +import type { Observable } from "rxjs"; +import { defer, of } from "rxjs"; -import { ApolloCache, InMemoryCache } from "@apollo/client/cache"; +import type { ApolloCache } from "@apollo/client/cache"; +import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; -import { ApolloLink, Operation } from "@apollo/client/link/core"; - +import type { Operation } from "@apollo/client/link/core"; +import { ApolloLink } from "@apollo/client/link/core"; import { ObservableStream, spyOnConsole, -} from "../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; describe("General functionality", () => { it("should not impact normal non-@client use", () => { diff --git a/src/__tests__/local-state/resolvers.ts b/src/__tests__/local-state/resolvers.ts index cbc966e56e7..7eae74c8d82 100644 --- a/src/__tests__/local-state/resolvers.ts +++ b/src/__tests__/local-state/resolvers.ts @@ -1,19 +1,17 @@ -import { DocumentNode, ExecutionResult } from "graphql"; +import type { DocumentNode, ExecutionResult } from "graphql"; import { gql } from "graphql-tag"; import { of } from "rxjs"; import { InMemoryCache, isReference } from "@apollo/client/cache"; -import { - ApolloClient, - NetworkStatus, - QueryResult, - Resolvers, -} from "@apollo/client/core"; +import type { QueryResult, Resolvers } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import { MockLink } from "@apollo/client/testing"; +import { ObservableStream } from "@apollo/client/testing/internal"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { LocalState } from "../../core/LocalState.js"; -import { ObservableStream } from "../../testing/internal/index.js"; const setupTestWithResolvers = ({ resolvers, diff --git a/src/__tests__/local-state/subscriptions.ts b/src/__tests__/local-state/subscriptions.ts index 3dac3ce8f22..fbf32e9549d 100644 --- a/src/__tests__/local-state/subscriptions.ts +++ b/src/__tests__/local-state/subscriptions.ts @@ -4,8 +4,7 @@ import { of } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; - -import { ObservableStream } from "../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; describe("Basic functionality", () => { it("should not break subscriptions", async () => { diff --git a/src/__tests__/mutationResults.ts b/src/__tests__/mutationResults.ts index 93b39687179..0396ed7eb67 100644 --- a/src/__tests__/mutationResults.ts +++ b/src/__tests__/mutationResults.ts @@ -1,15 +1,21 @@ -import { GraphQLError, GraphQLFormattedError } from "graphql"; +import type { GraphQLFormattedError } from "graphql"; +import { GraphQLError } from "graphql"; import { gql } from "graphql-tag"; import { cloneDeep } from "lodash"; -import { firstValueFrom, from, Observable, Subscription } from "rxjs"; +import type { Subscription } from "rxjs"; +import { firstValueFrom, from, Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { ApolloClient, FetchResult } from "@apollo/client/core"; +import type { FetchResult } from "@apollo/client/core"; +import { ApolloClient } from "@apollo/client/core"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; import { ApolloLink } from "@apollo/client/link/core"; -import { MockedResponse, mockSingleLink } from "@apollo/client/testing"; - -import { ObservableStream, spyOnConsole } from "../testing/internal/index.js"; +import type { MockedResponse } from "@apollo/client/testing"; +import { mockSingleLink } from "@apollo/client/testing"; +import { + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; describe("mutation results", () => { const query = gql` diff --git a/src/__tests__/optimistic.ts b/src/__tests__/optimistic.ts index 084f15df711..6ef06714ccb 100644 --- a/src/__tests__/optimistic.ts +++ b/src/__tests__/optimistic.ts @@ -3,28 +3,19 @@ import { assign, cloneDeep } from "lodash"; import { firstValueFrom, from, lastValueFrom, Observable } from "rxjs"; import { map, take, toArray } from "rxjs/operators"; -import { - Cache, - InMemoryCache, - NormalizedCacheObject, -} from "@apollo/client/cache"; -import { +import type { Cache, NormalizedCacheObject } from "@apollo/client/cache"; +import { InMemoryCache } from "@apollo/client/cache"; +import type { ApolloCache, - ApolloClient, - ApolloLink, - makeReference, MutationQueryReducersMap, TypedDocumentNode, } from "@apollo/client/core"; -import { - MockedResponse, - MockLink, - mockSingleLink, -} from "@apollo/client/testing"; +import { ApolloClient, ApolloLink, makeReference } from "@apollo/client/core"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, mockSingleLink } from "@apollo/client/testing"; +import { ObservableStream } from "@apollo/client/testing/internal"; import { addTypenameToDocument } from "@apollo/client/utilities"; -import { ObservableStream } from "../testing/internal/index.js"; - describe("optimistic mutation results", () => { const query = gql` query todoList { diff --git a/src/__tests__/refetchQueries.ts b/src/__tests__/refetchQueries.ts index 56a96ad93de..f851e8442df 100644 --- a/src/__tests__/refetchQueries.ts +++ b/src/__tests__/refetchQueries.ts @@ -1,5 +1,7 @@ -import { Observable, Subscription } from "rxjs"; +import type { Subscription } from "rxjs"; +import { Observable } from "rxjs"; +import type { TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient, ApolloLink, @@ -7,10 +9,8 @@ import { InMemoryCache, NetworkStatus, ObservableQuery, - TypedDocumentNode, } from "@apollo/client/core"; - -import { ObservableStream } from "../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; describe("client.refetchQueries", () => { it("is public and callable", async () => { diff --git a/src/__tests__/resultCacheCleaning.ts b/src/__tests__/resultCacheCleaning.ts index 9d3bcc79544..e9394e4262d 100644 --- a/src/__tests__/resultCacheCleaning.ts +++ b/src/__tests__/resultCacheCleaning.ts @@ -1,7 +1,8 @@ import { makeExecutableSchema } from "@graphql-tools/schema"; import { InMemoryCache } from "@apollo/client/cache"; -import { ApolloClient, gql, Resolvers } from "@apollo/client/core"; +import type { Resolvers } from "@apollo/client/core"; +import { ApolloClient, gql } from "@apollo/client/core"; import { SchemaLink } from "@apollo/client/link/schema"; describe("resultCache cleaning", () => { diff --git a/src/__tests__/subscribeToMore.ts b/src/__tests__/subscribeToMore.ts index e8769061216..382d44ed7bb 100644 --- a/src/__tests__/subscribeToMore.ts +++ b/src/__tests__/subscribeToMore.ts @@ -1,16 +1,19 @@ -import { DocumentNode, OperationDefinitionNode } from "graphql"; +import type { DocumentNode, OperationDefinitionNode } from "graphql"; import { gql } from "graphql-tag"; import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; -import { ApolloLink, Operation } from "@apollo/client/link/core"; +import type { Operation } from "@apollo/client/link/core"; +import { ApolloLink } from "@apollo/client/link/core"; import { mockObservableLink, mockSingleLink, wait, } from "@apollo/client/testing"; - -import { ObservableStream, spyOnConsole } from "../testing/internal/index.js"; +import { + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; const isSub = (operation: Operation) => (operation.query as DocumentNode).definitions diff --git a/src/cache/core/__tests__/cache.ts b/src/cache/core/__tests__/cache.ts index 666cbfa2a75..74b3fc0904b 100644 --- a/src/cache/core/__tests__/cache.ts +++ b/src/cache/core/__tests__/cache.ts @@ -1,10 +1,11 @@ import { expectTypeOf } from "expect-type"; import { gql } from "graphql-tag"; -import { ApolloCache, Cache, DataProxy } from "@apollo/client/cache"; -import { OperationVariables, Unmasked } from "@apollo/client/core"; +import type { Cache, DataProxy } from "@apollo/client/cache"; +import { ApolloCache } from "@apollo/client/cache"; +import type { OperationVariables, Unmasked } from "@apollo/client/core"; -import { Reference } from "../../../utilities/graphql/storeUtils.js"; +import type { Reference } from "../../../utilities/graphql/storeUtils.js"; class TestCache extends ApolloCache { constructor() { diff --git a/src/cache/inmemory/__tests__/cache.ts b/src/cache/inmemory/__tests__/cache.ts index 254899069b3..f171ee11a3f 100644 --- a/src/cache/inmemory/__tests__/cache.ts +++ b/src/cache/inmemory/__tests__/cache.ts @@ -1,20 +1,23 @@ import { expectTypeOf } from "expect-type"; import { disableFragmentWarnings, gql } from "graphql-tag"; -import { Cache, InMemoryCache, MissingFieldError } from "@apollo/client/cache"; -import { +import type { Cache } from "@apollo/client/cache"; +import { InMemoryCache, MissingFieldError } from "@apollo/client/cache"; +import type { DocumentNode, - isReference, - makeReference, - makeVar, Reference, TypedDocumentNode, } from "@apollo/client/core"; +import { isReference, makeReference, makeVar } from "@apollo/client/core"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { cloneDeep, defaultCacheSizes } from "@apollo/client/utilities"; -import { spyOnConsole } from "../../../testing/internal/index.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreReader } from "../readFromStore.js"; -import { InMemoryCacheConfig } from "../types.js"; +import type { InMemoryCacheConfig } from "../types.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreWriter } from "../writeToStore.js"; disableFragmentWarnings(); diff --git a/src/cache/inmemory/__tests__/diffAgainstStore.ts b/src/cache/inmemory/__tests__/diffAgainstStore.ts index f49411db5b3..47b2442d5f1 100644 --- a/src/cache/inmemory/__tests__/diffAgainstStore.ts +++ b/src/cache/inmemory/__tests__/diffAgainstStore.ts @@ -3,8 +3,12 @@ import { disableFragmentWarnings, gql } from "graphql-tag"; import { defaultDataIdFromObject, InMemoryCache } from "@apollo/client/cache"; import { MissingFieldError } from "@apollo/client/core"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreReader } from "../readFromStore.js"; -import { NormalizedCache, Reference } from "../types.js"; +import type { NormalizedCache, Reference } from "../types.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreWriter } from "../writeToStore.js"; import { diff --git a/src/cache/inmemory/__tests__/entityStore.ts b/src/cache/inmemory/__tests__/entityStore.ts index a26c4de80c7..68990cc14a7 100644 --- a/src/cache/inmemory/__tests__/entityStore.ts +++ b/src/cache/inmemory/__tests__/entityStore.ts @@ -1,13 +1,14 @@ -import { TypedDocumentNode } from "@graphql-typed-document-node/core"; -import { DocumentNode } from "graphql"; +import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; +import type { DocumentNode } from "graphql"; import { gql } from "graphql-tag"; +import type { ApolloCache } from "@apollo/client/cache"; import { - ApolloCache, EntityStore, InMemoryCache, MissingFieldError, } from "@apollo/client/cache"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { isReference, makeReference, @@ -15,14 +16,15 @@ import { } from "@apollo/client/utilities"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { spyOnConsole } from "../../../testing/internal/index.js"; -import { +import type { Reference, StoreValue, } from "../../../utilities/graphql/storeUtils.js"; -import { Cache } from "../../core/types/Cache.js"; +import type { Cache } from "../../core/types/Cache.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { supportsResultCaching } from "../entityStore.js"; -import { StoreObject } from "../types.js"; +import type { StoreObject } from "../types.js"; describe("EntityStore", () => { it("should support result caching if so configured", () => { diff --git a/src/cache/inmemory/__tests__/fragmentMatcher.ts b/src/cache/inmemory/__tests__/fragmentMatcher.ts index 6023fdad739..0f43c536187 100644 --- a/src/cache/inmemory/__tests__/fragmentMatcher.ts +++ b/src/cache/inmemory/__tests__/fragmentMatcher.ts @@ -1,10 +1,9 @@ -import { FragmentDefinitionNode, visit } from "graphql"; +import type { FragmentDefinitionNode } from "graphql"; +import { visit } from "graphql"; import { gql } from "graphql-tag"; import { InMemoryCache } from "@apollo/client/cache"; -import { hasOwn } from "../helpers.js"; - describe("fragment matching", () => { it("can match exact types with or without possibleTypes", () => { const cacheWithoutPossibleTypes = new InMemoryCache(); @@ -282,7 +281,7 @@ describe("policies.fragmentMatches", () => { const supertype = frag.typeCondition.name.value; expect("ABCDEF".split("")).toContain(supertype); - if (hasOwn.call(expected, supertype)) { + if (expected.hasOwnProperty(supertype)) { Object.keys(expected[supertype]).forEach((subtype) => { check(subtype, expected[supertype][subtype]); }); diff --git a/src/cache/inmemory/__tests__/fragmentRegistry.ts b/src/cache/inmemory/__tests__/fragmentRegistry.ts index 2093b06cbb1..73680008c5b 100644 --- a/src/cache/inmemory/__tests__/fragmentRegistry.ts +++ b/src/cache/inmemory/__tests__/fragmentRegistry.ts @@ -7,10 +7,9 @@ import { gql, NetworkStatus, } from "@apollo/client/core"; +import { ObservableStream } from "@apollo/client/testing/internal"; import { getFragmentDefinitions } from "@apollo/client/utilities"; -import { ObservableStream } from "../../../testing/internal/index.js"; - describe("FragmentRegistry", () => { it("can be passed to InMemoryCache", () => { const cache = new InMemoryCache({ diff --git a/src/cache/inmemory/__tests__/helpers.ts b/src/cache/inmemory/__tests__/helpers.ts index b785e279216..7b75d9a94e6 100644 --- a/src/cache/inmemory/__tests__/helpers.ts +++ b/src/cache/inmemory/__tests__/helpers.ts @@ -1,13 +1,13 @@ import { EntityStore, InMemoryCache } from "@apollo/client/cache"; -import { Cache } from "@apollo/client/core"; +import type { Cache } from "@apollo/client/core"; -import { StoreReader } from "../readFromStore.js"; -import { +import type { StoreReader } from "../readFromStore.js"; +import type { DiffQueryAgainstStoreOptions, NormalizedCache, NormalizedCacheObject, } from "../types.js"; -import { StoreWriter } from "../writeToStore.js"; +import type { StoreWriter } from "../writeToStore.js"; export function defaultNormalizedCacheFactory( seed?: NormalizedCacheObject diff --git a/src/cache/inmemory/__tests__/key-extractor.ts b/src/cache/inmemory/__tests__/key-extractor.ts index 26a5e93447d..19074281691 100644 --- a/src/cache/inmemory/__tests__/key-extractor.ts +++ b/src/cache/inmemory/__tests__/key-extractor.ts @@ -4,8 +4,10 @@ import { collectSpecifierPaths, extractKeyPath, getSpecifierPaths, + // not exported + // eslint-disable-next-line local-rules/no-relative-imports } from "../key-extractor.js"; -import { KeySpecifier } from "../policies.js"; +import type { KeySpecifier } from "../policies.js"; describe("keyFields and keyArgs extraction", () => { it("getSpecifierPaths should work for various specifiers", () => { diff --git a/src/cache/inmemory/__tests__/policies.ts b/src/cache/inmemory/__tests__/policies.ts index 3e9d7d83ab9..bd3264cee6c 100644 --- a/src/cache/inmemory/__tests__/policies.ts +++ b/src/cache/inmemory/__tests__/policies.ts @@ -5,27 +5,26 @@ import { makeVar, MissingFieldError, } from "@apollo/client/cache"; -import { - ApolloClient, +import type { DocumentNode, - NetworkStatus, OperationVariables, Reference, StoreObject, TypedDocumentNode, } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { MockLink } from "@apollo/client/testing/core"; +import { + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { relayStylePagination, stringifyForDisplay, } from "@apollo/client/utilities"; -import { - ObservableStream, - spyOnConsole, -} from "../../../testing/internal/index.js"; -import { FieldPolicy, StorageType } from "../policies.js"; -import { ReactiveVar } from "../reactiveVars.js"; +import type { FieldPolicy, StorageType } from "../policies.js"; +import type { ReactiveVar } from "../reactiveVars.js"; function reverse(s: string) { return s.split("").reverse().join(""); diff --git a/src/cache/inmemory/__tests__/readFromStore.ts b/src/cache/inmemory/__tests__/readFromStore.ts index f49a83e03a1..cca9d118ee7 100644 --- a/src/cache/inmemory/__tests__/readFromStore.ts +++ b/src/cache/inmemory/__tests__/readFromStore.ts @@ -2,17 +2,15 @@ import { gql } from "graphql-tag"; import { assign, omit } from "lodash"; import { InMemoryCache, MissingFieldError } from "@apollo/client/cache"; -import { - isReference, - makeReference, - Reference, - TypedDocumentNode, -} from "@apollo/client/core"; +import type { Reference, TypedDocumentNode } from "@apollo/client/core"; +import { isReference, makeReference } from "@apollo/client/core"; import { defaultCacheSizes } from "@apollo/client/utilities"; -import { Cache } from "../../core/types/Cache.js"; +import type { Cache } from "../../core/types/Cache.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreReader } from "../readFromStore.js"; -import { StoreObject } from "../types.js"; +import type { StoreObject } from "../types.js"; import { defaultNormalizedCacheFactory, diff --git a/src/cache/inmemory/__tests__/recordingCache.ts b/src/cache/inmemory/__tests__/recordingCache.ts index 5b7ab057e75..895c3e3b7e8 100644 --- a/src/cache/inmemory/__tests__/recordingCache.ts +++ b/src/cache/inmemory/__tests__/recordingCache.ts @@ -1,6 +1,6 @@ import { EntityStore, InMemoryCache, Policies } from "@apollo/client/cache"; -import { NormalizedCacheObject, StoreObject } from "../types.js"; +import type { NormalizedCacheObject, StoreObject } from "../types.js"; describe("Optimistic EntityStore layering", () => { function makeLayer(root: EntityStore) { diff --git a/src/cache/inmemory/__tests__/roundtrip.ts b/src/cache/inmemory/__tests__/roundtrip.ts index 9544e583de1..7fb629ec444 100644 --- a/src/cache/inmemory/__tests__/roundtrip.ts +++ b/src/cache/inmemory/__tests__/roundtrip.ts @@ -1,11 +1,15 @@ -import { DocumentNode } from "graphql"; +import type { DocumentNode } from "graphql"; import { gql } from "graphql-tag"; import { EntityStore, InMemoryCache } from "@apollo/client/cache"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { __DEV__ } from "@apollo/client/utilities/environment"; -import { spyOnConsole } from "../../../testing/internal/index.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreReader } from "../readFromStore.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreWriter } from "../writeToStore.js"; import { readQueryFromStore, withError, writeQueryToStore } from "./helpers.js"; diff --git a/src/cache/inmemory/__tests__/writeToStore.ts b/src/cache/inmemory/__tests__/writeToStore.ts index 5714fa100d7..9c1c27430c8 100644 --- a/src/cache/inmemory/__tests__/writeToStore.ts +++ b/src/cache/inmemory/__tests__/writeToStore.ts @@ -1,4 +1,4 @@ -import { +import type { ASTNode, DefinitionNode, DocumentNode, @@ -10,22 +10,25 @@ import { gql } from "graphql-tag"; import { assign, omit } from "lodash"; import { InMemoryCache } from "@apollo/client/cache"; -import { TypedDocumentNode } from "@apollo/client/core"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { spyOnConsole } from "@apollo/client/testing/internal"; +import type { Reference, StoreObject } from "@apollo/client/utilities"; import { addTypenameToDocument, cloneDeep, getMainDefinition, isReference, makeReference, - Reference, storeKeyNameFromField, - StoreObject, } from "@apollo/client/utilities"; import { invariant } from "@apollo/client/utilities/invariant"; -import { spyOnConsole } from "../../../testing/internal/index.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { extractFragmentContext } from "../helpers.js"; -import { KeyFieldsFunction } from "../policies.js"; +import type { KeyFieldsFunction } from "../policies.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { StoreWriter } from "../writeToStore.js"; import { defaultNormalizedCacheFactory, writeQueryToStore } from "./helpers.js"; diff --git a/src/core/__tests__/ApolloClient/general.test.ts b/src/core/__tests__/ApolloClient/general.test.ts index 96aba2063e5..aa1f97da4a1 100644 --- a/src/core/__tests__/ApolloClient/general.test.ts +++ b/src/core/__tests__/ApolloClient/general.test.ts @@ -1,38 +1,32 @@ // externals -import { DocumentNode, GraphQLError } from "graphql"; +import type { DocumentNode } from "graphql"; +import { GraphQLError } from "graphql"; import { gql } from "graphql-tag"; -import { Observable, Observer } from "rxjs"; +import type { Observer } from "rxjs"; +import { Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, - ApolloQueryResult, - NetworkStatus, -} from "@apollo/client/core"; +import type { ApolloQueryResult } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; -import { - ApolloLink, - FetchResult, - type RequestHandler, -} from "@apollo/client/link/core"; +import type { FetchResult, RequestHandler } from "@apollo/client/link/core"; +import { ApolloLink } from "@apollo/client/link/core"; +import { MockLink } from "@apollo/client/testing"; import { wait } from "@apollo/client/testing/core"; +import { + mockDeferStream, + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { addTypenameToDocument, print } from "@apollo/client/utilities"; import { InvariantError, setVerbosity, } from "@apollo/client/utilities/invariant"; -import { - MockApolloLink, - MockLink, -} from "../../../testing/core/mocking/mockLink.js"; -import { - mockDeferStream, - ObservableStream, - spyOnConsole, -} from "../../../testing/internal/index.js"; -import { QueryManager } from "../../QueryManager.js"; -import { +import type { MockApolloLink } from "../../../testing/core/mocking/mockLink.js"; +import type { QueryManager } from "../../QueryManager.js"; +import type { WatchQueryFetchPolicy, WatchQueryOptions, } from "../../watchQueryOptions.js"; diff --git a/src/core/__tests__/ApolloClient/links.test.ts b/src/core/__tests__/ApolloClient/links.test.ts index 2b1c08625ce..7fb459c005f 100644 --- a/src/core/__tests__/ApolloClient/links.test.ts +++ b/src/core/__tests__/ApolloClient/links.test.ts @@ -1,14 +1,11 @@ import { print } from "graphql"; import { gql } from "graphql-tag"; -import { map, of, Subscription } from "rxjs"; +import type { Subscription } from "rxjs"; +import { map, of } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, - NextLink, - Operation, - Reference, -} from "@apollo/client/core"; +import type { NextLink, Operation, Reference } from "@apollo/client/core"; +import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import { MockSubscriptionLink } from "@apollo/client/testing/core"; diff --git a/src/core/__tests__/ApolloClient/multiple-results.test.ts b/src/core/__tests__/ApolloClient/multiple-results.test.ts index f5780fcce44..f20e5673909 100644 --- a/src/core/__tests__/ApolloClient/multiple-results.test.ts +++ b/src/core/__tests__/ApolloClient/multiple-results.test.ts @@ -4,8 +4,7 @@ import { gql } from "graphql-tag"; import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { MockSubscriptionLink, wait } from "@apollo/client/testing/core"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; describe("mutiple results", () => { it("allows multiple query results from link", async () => { diff --git a/src/core/__tests__/ObservableQuery.ts b/src/core/__tests__/ObservableQuery.ts index 77de556192e..acdd49231b7 100644 --- a/src/core/__tests__/ObservableQuery.ts +++ b/src/core/__tests__/ObservableQuery.ts @@ -1,20 +1,21 @@ -import { TypedDocumentNode } from "@graphql-typed-document-node/core"; +import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { waitFor } from "@testing-library/react"; import { expectTypeOf } from "expect-type"; import { GraphQLError } from "graphql"; import { gql } from "graphql-tag"; -import { from, Observable, ObservedValueOf, Observer, of, Subject } from "rxjs"; +import type { ObservedValueOf, Observer } from "rxjs"; +import { from, Observable, of, Subject } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, +import type { ApolloQueryResult, - NetworkStatus, ObservableQuery, WatchQueryFetchPolicy, } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; -import { ApolloLink, FetchResult } from "@apollo/client/link/core"; +import type { FetchResult } from "@apollo/client/link/core"; +import { ApolloLink } from "@apollo/client/link/core"; import { MockLink, MockSubscriptionLink, @@ -22,17 +23,16 @@ import { wait, } from "@apollo/client/testing"; import { - DeepPartial, + ObservableStream, + spyOnConsole, +} from "@apollo/client/testing/internal"; +import type { DeepPartial } from "@apollo/client/utilities"; +import { DocumentTransform, removeDirectivesFromDocument, } from "@apollo/client/utilities"; -import { - ObservableStream, - spyOnConsole, -} from "../../testing/internal/index.js"; -import type { ObservableAndInfo } from "../QueryManager.js"; -import { QueryManager } from "../QueryManager.js"; +import type { ObservableAndInfo, QueryManager } from "../QueryManager.js"; export const mockFetchQuery = (queryManager: QueryManager) => { const mocks = { diff --git a/src/core/__tests__/equalByQuery.ts b/src/core/__tests__/equalByQuery.ts index 05886dbaebb..abec4f44d88 100644 --- a/src/core/__tests__/equalByQuery.ts +++ b/src/core/__tests__/equalByQuery.ts @@ -1,11 +1,10 @@ import { GraphQLError } from "graphql"; -import { - CombinedGraphQLErrors, - gql, - TypedDocumentNode, -} from "@apollo/client/core"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { CombinedGraphQLErrors, gql } from "@apollo/client/core"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { equalByQuery } from "../equalByQuery.js"; describe("equalByQuery", () => { diff --git a/src/core/__tests__/fetchPolicies.ts b/src/core/__tests__/fetchPolicies.ts index ce3161959ff..2cb797fa5f0 100644 --- a/src/core/__tests__/fetchPolicies.ts +++ b/src/core/__tests__/fetchPolicies.ts @@ -1,22 +1,19 @@ -import { TypedDocumentNode } from "@graphql-typed-document-node/core"; +import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { gql } from "graphql-tag"; import { map, Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, - NetworkStatus, - ObservableQuery, -} from "@apollo/client/core"; +import type { ObservableQuery } from "@apollo/client/core"; +import { ApolloClient, NetworkStatus } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import { mockSingleLink } from "@apollo/client/testing"; - import { ObservableStream, spyOnConsole, -} from "../../testing/internal/index.js"; -import { ApolloQueryResult } from "../types.js"; -import { +} from "@apollo/client/testing/internal"; + +import type { ApolloQueryResult } from "../types.js"; +import type { WatchQueryFetchPolicy, WatchQueryOptions, } from "../watchQueryOptions.js"; diff --git a/src/link/batch-http/__tests__/batchHttpLink.ts b/src/link/batch-http/__tests__/batchHttpLink.ts index 7a3bff02704..be8930f0ac8 100644 --- a/src/link/batch-http/__tests__/batchHttpLink.ts +++ b/src/link/batch-http/__tests__/batchHttpLink.ts @@ -1,12 +1,14 @@ import fetchMock from "fetch-mock"; -import { ASTNode, print, stripIgnoredCharacters } from "graphql"; +import type { ASTNode } from "graphql"; +import { print, stripIgnoredCharacters } from "graphql"; import { gql } from "graphql-tag"; -import { map, Observable, Observer, Subscription } from "rxjs"; +import type { Observer, Subscription } from "rxjs"; +import { map, Observable } from "rxjs"; import { BatchHttpLink } from "@apollo/client/link/batch-http"; -import { ApolloLink, execute, FetchResult } from "@apollo/client/link/core"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import type { FetchResult } from "@apollo/client/link/core"; +import { ApolloLink, execute } from "@apollo/client/link/core"; +import { ObservableStream } from "@apollo/client/testing/internal"; const sampleQuery = gql` query SampleQuery { diff --git a/src/link/batch/__tests__/batchLink.ts b/src/link/batch/__tests__/batchLink.ts index 0573de31612..bfe9a1e1552 100644 --- a/src/link/batch/__tests__/batchLink.ts +++ b/src/link/batch/__tests__/batchLink.ts @@ -5,10 +5,14 @@ import { EMPTY, map, Observable, of } from "rxjs"; import { BatchLink, OperationBatcher } from "@apollo/client/link/batch"; import { ApolloLink, execute } from "@apollo/client/link/core"; import { wait } from "@apollo/client/testing"; - -import { ObservableStream } from "../../../testing/internal/index.js"; -import { FetchResult, GraphQLRequest, Operation } from "../../core/types.js"; -import { BatchableRequest, BatchHandler } from "../batchLink.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; + +import type { + FetchResult, + GraphQLRequest, + Operation, +} from "../../core/types.js"; +import type { BatchableRequest, BatchHandler } from "../batchLink.js"; interface MockedResponse { request: GraphQLRequest; diff --git a/src/link/context/__tests__/index.ts b/src/link/context/__tests__/index.ts index a6d76d697b1..960d7564d6a 100644 --- a/src/link/context/__tests__/index.ts +++ b/src/link/context/__tests__/index.ts @@ -4,8 +4,7 @@ import { Observable, of } from "rxjs"; import { setContext } from "@apollo/client/link/context"; import { ApolloLink, execute } from "@apollo/client/link/core"; import { wait } from "@apollo/client/testing"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; const sleep = (ms: number) => new Promise((s) => setTimeout(s, ms)); const query = gql` diff --git a/src/link/core/__tests__/ApolloLink.ts b/src/link/core/__tests__/ApolloLink.ts index 49b2d566657..bb7d828990d 100644 --- a/src/link/core/__tests__/ApolloLink.ts +++ b/src/link/core/__tests__/ApolloLink.ts @@ -3,9 +3,14 @@ import { gql } from "graphql-tag"; import { EMPTY, map, Observable, of } from "rxjs"; import { ApolloLink, execute } from "@apollo/client/link/core"; - -import { ObservableStream } from "../../../testing/internal/index.js"; -import { FetchResult, GraphQLRequest, NextLink, Operation } from "../types.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; + +import type { + FetchResult, + GraphQLRequest, + NextLink, + Operation, +} from "../types.js"; class SetContextLink extends ApolloLink { constructor( diff --git a/src/link/error/__tests__/index.ts b/src/link/error/__tests__/index.ts index 4d946403392..745baabef09 100644 --- a/src/link/error/__tests__/index.ts +++ b/src/link/error/__tests__/index.ts @@ -8,12 +8,11 @@ import { } from "@apollo/client/errors"; import { ApolloLink, execute } from "@apollo/client/link/core"; import { ErrorLink, onError } from "@apollo/client/link/error"; - import { mockDeferStream, mockMultipartSubscriptionStream, ObservableStream, -} from "../../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; describe("error handling", () => { it("has an easy way to handle GraphQL errors", async () => { diff --git a/src/link/http/__tests__/HttpLink.ts b/src/link/http/__tests__/HttpLink.ts index d50eba04bd9..663fbb6a441 100644 --- a/src/link/http/__tests__/HttpLink.ts +++ b/src/link/http/__tests__/HttpLink.ts @@ -1,23 +1,25 @@ import { TextDecoder } from "util"; import fetchMock from "fetch-mock"; -import { ASTNode, print, stripIgnoredCharacters } from "graphql"; +import type { ASTNode } from "graphql"; +import { print, stripIgnoredCharacters } from "graphql"; import { gql } from "graphql-tag"; -import { map, Observable, Observer, Subscription } from "rxjs"; +import type { Observer, Subscription } from "rxjs"; +import { map, Observable } from "rxjs"; import { ReadableStream } from "web-streams-polyfill"; -import { FetchResult, ServerError } from "@apollo/client"; +import type { FetchResult, ServerError } from "@apollo/client"; +import type { ServerParseError } from "@apollo/client/errors"; import { CombinedProtocolErrors, PROTOCOL_ERRORS_SYMBOL, - ServerParseError, } from "@apollo/client/errors"; import { ApolloLink, execute } from "@apollo/client/link/core"; import { createHttpLink, HttpLink } from "@apollo/client/link/http"; import { wait } from "@apollo/client/testing"; +import { ObservableStream } from "@apollo/client/testing/internal"; -import { ObservableStream } from "../../../testing/internal/index.js"; -import { ClientParseError } from "../serializeFetchParameter.js"; +import type { ClientParseError } from "../serializeFetchParameter.js"; import { voidFetchDuringEachTest } from "./helpers.js"; diff --git a/src/link/http/__tests__/responseIterator.ts b/src/link/http/__tests__/responseIterator.ts index 236301c7650..01e9b53113d 100644 --- a/src/link/http/__tests__/responseIterator.ts +++ b/src/link/http/__tests__/responseIterator.ts @@ -6,10 +6,9 @@ import { ReadableStream } from "web-streams-polyfill"; import { execute } from "@apollo/client/link/core"; import { HttpLink } from "@apollo/client/link/http"; +import { ObservableStream } from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { ObservableStream } from "../../../testing/internal/index.js"; - const sampleDeferredQuery = gql` query SampleDeferredQuery { stub { diff --git a/src/link/http/__tests__/responseIteratorNoAsyncIterator.ts b/src/link/http/__tests__/responseIteratorNoAsyncIterator.ts index 721b207abd9..f5263b60f27 100644 --- a/src/link/http/__tests__/responseIteratorNoAsyncIterator.ts +++ b/src/link/http/__tests__/responseIteratorNoAsyncIterator.ts @@ -5,8 +5,7 @@ import { ReadableStream } from "web-streams-polyfill"; import { execute } from "@apollo/client/link/core"; import { HttpLink } from "@apollo/client/link/http"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; const sampleDeferredQuery = gql` query SampleDeferredQuery { diff --git a/src/link/http/__tests__/selectHttpOptionsAndBody.ts b/src/link/http/__tests__/selectHttpOptionsAndBody.ts index eaa3366e16d..8e9cedb434e 100644 --- a/src/link/http/__tests__/selectHttpOptionsAndBody.ts +++ b/src/link/http/__tests__/selectHttpOptionsAndBody.ts @@ -1,4 +1,5 @@ -import { ASTNode, print, stripIgnoredCharacters } from "graphql"; +import type { ASTNode, print } from "graphql"; +import { stripIgnoredCharacters } from "graphql"; import { gql } from "graphql-tag"; import { diff --git a/src/link/persisted-queries/__tests__/persisted-queries.test.ts b/src/link/persisted-queries/__tests__/persisted-queries.test.ts index f171481d956..3b356a5dfd8 100644 --- a/src/link/persisted-queries/__tests__/persisted-queries.test.ts +++ b/src/link/persisted-queries/__tests__/persisted-queries.test.ts @@ -13,8 +13,7 @@ import { VERSION, } from "@apollo/client/link/persisted-queries"; import { wait } from "@apollo/client/testing"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; // Necessary configuration in order to mock multiple requests // to a single (/graphql) endpoint diff --git a/src/link/persisted-queries/__tests__/react.test.tsx b/src/link/persisted-queries/__tests__/react.test.tsx index c06d3cfa4a8..bb173e3f314 100644 --- a/src/link/persisted-queries/__tests__/react.test.tsx +++ b/src/link/persisted-queries/__tests__/react.test.tsx @@ -8,7 +8,8 @@ import * as React from "react"; import * as ReactDOM from "react-dom/server"; import { InMemoryCache as Cache } from "@apollo/client/cache"; -import { ApolloClient, OperationVariables } from "@apollo/client/core"; +import type { OperationVariables } from "@apollo/client/core"; +import { ApolloClient } from "@apollo/client/core"; import { createHttpLink } from "@apollo/client/link/http"; import { createPersistedQueryLink as createPersistedQuery, diff --git a/src/link/remove-typename/__tests__/removeTypenameFromVariables.ts b/src/link/remove-typename/__tests__/removeTypenameFromVariables.ts index 5a27405e1ea..f9683038715 100644 --- a/src/link/remove-typename/__tests__/removeTypenameFromVariables.ts +++ b/src/link/remove-typename/__tests__/removeTypenameFromVariables.ts @@ -1,7 +1,7 @@ import { firstValueFrom, of } from "rxjs"; import { gql } from "@apollo/client/core"; -import { ApolloLink, Operation } from "@apollo/client/link/core"; +import type { ApolloLink, Operation } from "@apollo/client/link/core"; import { KEEP, removeTypenameFromVariables, diff --git a/src/link/retry/__tests__/delayFunction.ts b/src/link/retry/__tests__/delayFunction.ts index d63be510c12..bb1f9c00ace 100644 --- a/src/link/retry/__tests__/delayFunction.ts +++ b/src/link/retry/__tests__/delayFunction.ts @@ -1,3 +1,5 @@ +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { buildDelayFunction } from "../delayFunction.js"; describe("buildDelayFunction", () => { diff --git a/src/link/retry/__tests__/retryFunction.ts b/src/link/retry/__tests__/retryFunction.ts index 16cd6a44caa..7a9b49bab1d 100644 --- a/src/link/retry/__tests__/retryFunction.ts +++ b/src/link/retry/__tests__/retryFunction.ts @@ -1,4 +1,6 @@ -import { Operation } from "../../core/types.js"; +import type { Operation } from "../../core/types.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { buildRetryFunction } from "../retryFunction.js"; describe("buildRetryFunction", () => { diff --git a/src/link/retry/__tests__/retryLink.ts b/src/link/retry/__tests__/retryLink.ts index 3b1b23a3fa8..72fb7f2f73a 100644 --- a/src/link/retry/__tests__/retryLink.ts +++ b/src/link/retry/__tests__/retryLink.ts @@ -4,11 +4,10 @@ import { Observable, of, throwError } from "rxjs"; import { CombinedProtocolErrors } from "@apollo/client/core"; import { ApolloLink, execute } from "@apollo/client/link/core"; import { RetryLink } from "@apollo/client/link/retry"; - import { mockMultipartSubscriptionStream, ObservableStream, -} from "../../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; const query = gql` { diff --git a/src/link/schema/__tests__/schemaLink.ts b/src/link/schema/__tests__/schemaLink.ts index b9b47d600f0..65f357248df 100644 --- a/src/link/schema/__tests__/schemaLink.ts +++ b/src/link/schema/__tests__/schemaLink.ts @@ -3,8 +3,7 @@ import { gql } from "graphql-tag"; import { execute } from "@apollo/client/link/core"; import { SchemaLink } from "@apollo/client/link/schema"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; const sampleQuery = gql` query SampleQuery { diff --git a/src/link/subscriptions/__tests__/graphqlWsLink.ts b/src/link/subscriptions/__tests__/graphqlWsLink.ts index 17aacdba16a..43a696be48a 100644 --- a/src/link/subscriptions/__tests__/graphqlWsLink.ts +++ b/src/link/subscriptions/__tests__/graphqlWsLink.ts @@ -1,7 +1,8 @@ -import { ExecutionResult, GraphQLError } from "graphql"; +import type { ExecutionResult } from "graphql"; +import { GraphQLError } from "graphql"; import { gql } from "graphql-tag"; -import { Client } from "graphql-ws"; -import { Observable } from "rxjs"; +import type { Client } from "graphql-ws"; +import type { Observable } from "rxjs"; import { CombinedGraphQLErrors } from "@apollo/client/errors"; import { execute } from "@apollo/client/link/core"; diff --git a/src/link/ws/__tests__/webSocketLink.ts b/src/link/ws/__tests__/webSocketLink.ts index 3bf5aeb2430..3f8af17f98d 100644 --- a/src/link/ws/__tests__/webSocketLink.ts +++ b/src/link/ws/__tests__/webSocketLink.ts @@ -1,12 +1,11 @@ -import { ExecutionResult } from "graphql"; +import type { ExecutionResult } from "graphql"; import { gql } from "graphql-tag"; import { Observable, of } from "rxjs"; import { SubscriptionClient } from "subscriptions-transport-ws"; import { execute } from "@apollo/client/link/core"; import { WebSocketLink } from "@apollo/client/link/ws"; - -import { ObservableStream } from "../../../testing/internal/index.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; const query = gql` query SampleQuery { diff --git a/src/masking/__tests__/maskFragment.test.ts b/src/masking/__tests__/maskFragment.test.ts index dd182746839..6ba684c40dd 100644 --- a/src/masking/__tests__/maskFragment.test.ts +++ b/src/masking/__tests__/maskFragment.test.ts @@ -1,8 +1,10 @@ import { gql, InMemoryCache } from "@apollo/client/core"; import { maskFragment } from "@apollo/client/masking"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { spyOnConsole } from "../../testing/internal/index.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { deepFreeze } from "../../utilities/common/maybeDeepFreeze.js"; test("returns null when data is null", () => { diff --git a/src/masking/__tests__/maskOperation.test.ts b/src/masking/__tests__/maskOperation.test.ts index 7bc714a1663..f62336e24bf 100644 --- a/src/masking/__tests__/maskOperation.test.ts +++ b/src/masking/__tests__/maskOperation.test.ts @@ -1,9 +1,11 @@ import { gql, InMemoryCache } from "@apollo/client/core"; import { maskOperation } from "@apollo/client/masking"; +import { spyOnConsole, withProdMode } from "@apollo/client/testing/internal"; import { __DEV__ } from "@apollo/client/utilities/environment"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { spyOnConsole, withProdMode } from "../../testing/internal/index.js"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { deepFreeze } from "../../utilities/common/maybeDeepFreeze.js"; test("throws when passing document with no operation to maskOperation", () => { diff --git a/src/react/context/__tests__/ApolloProvider.test.tsx b/src/react/context/__tests__/ApolloProvider.test.tsx index 97a49154e50..002529a724e 100644 --- a/src/react/context/__tests__/ApolloProvider.test.tsx +++ b/src/react/context/__tests__/ApolloProvider.test.tsx @@ -6,8 +6,8 @@ import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import { ApolloProvider, getApolloContext } from "@apollo/client/react/context"; -import { ApolloContextValue } from "../ApolloContext.js"; -import { ApolloProviderProps } from "../ApolloProvider.js"; +import type { ApolloContextValue } from "../ApolloContext.js"; +import type { ApolloProviderProps } from "../ApolloProvider.js"; describe(" Component", () => { const client = new ApolloClient({ diff --git a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx index 8e3f58a8d82..6c819bed675 100644 --- a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx +++ b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx @@ -1,8 +1,8 @@ import { act, renderHook, screen } from "@testing-library/react"; +import type { RenderStream } from "@testing-library/react-render-stream"; import { createRenderStream, disableActEnvironment, - RenderStream, useTrackRenders, } from "@testing-library/react-render-stream"; import { userEvent } from "@testing-library/user-event"; @@ -10,67 +10,66 @@ import equal from "@wry/equality"; import { expectTypeOf } from "expect-type"; import { GraphQLError } from "graphql"; import React, { Suspense } from "react"; -import { - ErrorBoundary as ReactErrorBoundary, - FallbackProps, -} from "react-error-boundary"; +import type { FallbackProps } from "react-error-boundary"; +import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary"; import { Observable, of } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; +import type { ErrorPolicy, TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient, ApolloLink, CombinedGraphQLErrors, - ErrorPolicy, gql, NetworkStatus, split, - TypedDocumentNode, } from "@apollo/client/core"; -import { Masked, MaskedDocumentNode } from "@apollo/client/masking"; +import type { Masked, MaskedDocumentNode } from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react/context"; import { skipToken, useBackgroundQuery, useReadQuery, } from "@apollo/client/react/hooks"; -import { QueryRef, QueryReference } from "@apollo/client/react/internal"; +import type { QueryRef, QueryReference } from "@apollo/client/react/internal"; +import type { MockedResponse } from "@apollo/client/testing"; import { - MockedResponse, MockLink, mockSingleLink, MockSubscriptionLink, wait, } from "@apollo/client/testing"; +import type { + PaginatedCaseData, + SimpleCaseData, + VariablesCaseData, + VariablesCaseVariables, +} from "@apollo/client/testing/internal"; +import { + addDelayToMocks, + createClientWrapper, + createMockWrapper, + setupMaskedVariablesCase, + setupPaginatedCase, + setupSimpleCase, + setupVariablesCase, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; +import type { DeepPartial } from "@apollo/client/utilities"; import { concatPagination, - DeepPartial, getMainDefinition, offsetLimitPagination, } from "@apollo/client/utilities"; -import { +import type { RefetchWritePolicy, SubscribeToMoreFunction, SubscribeToMoreOptions, } from "../../../core/watchQueryOptions.js"; -import { - addDelayToMocks, - createClientWrapper, - createMockWrapper, - PaginatedCaseData, - setupPaginatedCase, - setupSimpleCase, - setupVariablesCase, - SimpleCaseData, - spyOnConsole, - VariablesCaseData, - VariablesCaseVariables, -} from "../../../testing/internal/index.js"; -import { +import type { MaskedVariablesCaseData, - setupMaskedVariablesCase, UnmaskedVariablesCaseData, } from "../../../testing/internal/scenarios/index.js"; diff --git a/src/react/hooks/__tests__/useFragment.test.tsx b/src/react/hooks/__tests__/useFragment.test.tsx index d9bca647c49..d3a70251ff4 100644 --- a/src/react/hooks/__tests__/useFragment.test.tsx +++ b/src/react/hooks/__tests__/useFragment.test.tsx @@ -17,27 +17,29 @@ import { import { userEvent } from "@testing-library/user-event"; import { expectTypeOf } from "expect-type"; import * as React from "react"; -import { Observable, Observer } from "rxjs"; +import type { Observer } from "rxjs"; +import { Observable } from "rxjs"; -import { - ApolloClient, - ApolloLink, +import type { DocumentNode, FetchResult, - gql, - InMemoryCache, Reference, StoreObject, TypedDocumentNode, } from "@apollo/client/core"; -import { FragmentType } from "@apollo/client/masking"; +import { + ApolloClient, + ApolloLink, + gql, + InMemoryCache, +} from "@apollo/client/core"; +import type { FragmentType } from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react/context"; import { useFragment, useQuery } from "@apollo/client/react/hooks"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; import { concatPagination } from "@apollo/client/utilities"; -import { spyOnConsole } from "../../../testing/internal/index.js"; - describe("useFragment", () => { it("is importable and callable", () => { expect(typeof useFragment).toBe("function"); diff --git a/src/react/hooks/__tests__/useLazyQuery.test.tsx b/src/react/hooks/__tests__/useLazyQuery.test.tsx index 8e3e7513b58..e5e73075a45 100644 --- a/src/react/hooks/__tests__/useLazyQuery.test.tsx +++ b/src/react/hooks/__tests__/useLazyQuery.test.tsx @@ -11,19 +11,25 @@ import React from "react"; import { ErrorBoundary } from "react-error-boundary"; import { Observable } from "rxjs"; +import type { + ErrorPolicy, + QueryResult, + RefetchWritePolicy, + TypedDocumentNode, + WatchQueryFetchPolicy, +} from "@apollo/client/core"; import { ApolloClient, ApolloLink, CombinedGraphQLErrors, - ErrorPolicy, InMemoryCache, NetworkStatus, - QueryResult, - RefetchWritePolicy, - TypedDocumentNode, - WatchQueryFetchPolicy, } from "@apollo/client/core"; -import { Masked, MaskedDocumentNode, Unmasked } from "@apollo/client/masking"; +import type { + Masked, + MaskedDocumentNode, + Unmasked, +} from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react"; import { useLazyQuery } from "@apollo/client/react/hooks"; import { @@ -32,17 +38,16 @@ import { MockSubscriptionLink, wait, } from "@apollo/client/testing"; -import { MockedProvider } from "@apollo/client/testing/react"; -import { DeepPartial } from "@apollo/client/utilities"; -import { InvariantError } from "@apollo/client/utilities/invariant"; - +import type { VariablesCaseVariables } from "@apollo/client/testing/internal"; import { renderAsync, setupSimpleCase, setupVariablesCase, spyOnConsole, - VariablesCaseVariables, -} from "../../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; +import { MockedProvider } from "@apollo/client/testing/react"; +import type { DeepPartial } from "@apollo/client/utilities"; +import { InvariantError } from "@apollo/client/utilities/invariant"; describe("useLazyQuery Hook", () => { const helloQuery: TypedDocumentNode<{ diff --git a/src/react/hooks/__tests__/useLoadableQuery.test.tsx b/src/react/hooks/__tests__/useLoadableQuery.test.tsx index 809cf9777c1..8542612e78f 100644 --- a/src/react/hooks/__tests__/useLoadableQuery.test.tsx +++ b/src/react/hooks/__tests__/useLoadableQuery.test.tsx @@ -1,9 +1,11 @@ import { act, renderHook, screen, waitFor } from "@testing-library/react"; -import { +import type { AsyncRenderFn, + RenderStream, +} from "@testing-library/react-render-stream"; +import { createRenderStream, disableActEnvironment, - RenderStream, useTrackRenders, } from "@testing-library/react-render-stream"; import { userEvent } from "@testing-library/user-event"; @@ -14,49 +16,48 @@ import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary"; import { Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; +import type { + ErrorPolicy, + OperationVariables, + RefetchWritePolicy, + SubscribeToMoreOptions, + TypedDocumentNode, +} from "@apollo/client/core"; import { ApolloClient, ApolloLink, CombinedGraphQLErrors, - ErrorPolicy, gql, NetworkStatus, - OperationVariables, - RefetchWritePolicy, split, - SubscribeToMoreOptions, - TypedDocumentNode, } from "@apollo/client/core"; -import { QueryRef } from "@apollo/client/react"; +import type { QueryRef } from "@apollo/client/react"; import { ApolloProvider } from "@apollo/client/react/context"; import { useLoadableQuery, useReadQuery } from "@apollo/client/react/hooks"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink, wait } from "@apollo/client/testing"; +import type { SimpleCaseData } from "@apollo/client/testing/internal"; import { - MockedResponse, - MockLink, - MockSubscriptionLink, - wait, -} from "@apollo/client/testing"; -import { - MockedProvider, - MockedProviderProps, -} from "@apollo/client/testing/react"; + renderAsync, + setupPaginatedCase, + setupSimpleCase, + spyOnConsole, +} from "@apollo/client/testing/internal"; +import type { MockedProviderProps } from "@apollo/client/testing/react"; +import { MockedProvider } from "@apollo/client/testing/react"; +import type { DeepPartial } from "@apollo/client/utilities"; import { concatPagination, - DeepPartial, getMainDefinition, offsetLimitPagination, } from "@apollo/client/utilities"; import { invariant, InvariantError } from "@apollo/client/utilities/invariant"; -import { SubscribeToMoreFunction } from "../../../core/watchQueryOptions.js"; -import { - renderAsync, - setupPaginatedCase, - setupSimpleCase, - SimpleCaseData, - spyOnConsole, -} from "../../../testing/internal/index.js"; -import { FetchMoreFunction, RefetchFunction } from "../../internal/types.js"; +import type { SubscribeToMoreFunction } from "../../../core/watchQueryOptions.js"; +import type { + FetchMoreFunction, + RefetchFunction, +} from "../../internal/types.js"; const IS_REACT_19 = React.version.startsWith("19"); diff --git a/src/react/hooks/__tests__/useMutation.test.tsx b/src/react/hooks/__tests__/useMutation.test.tsx index 64b4f9aec6b..d845bdf8103 100644 --- a/src/react/hooks/__tests__/useMutation.test.tsx +++ b/src/react/hooks/__tests__/useMutation.test.tsx @@ -19,32 +19,33 @@ import React, { useEffect } from "react"; import { Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; +import type { + Cache, + ObservableQuery, + QueryResult, + TypedDocumentNode, +} from "@apollo/client/core"; import { ApolloClient, ApolloLink, - Cache, CombinedGraphQLErrors, NetworkStatus, - ObservableQuery, - QueryResult, - TypedDocumentNode, } from "@apollo/client/core"; import { BatchHttpLink } from "@apollo/client/link/batch-http"; -import { FetchResult } from "@apollo/client/link/core"; -import { Masked } from "@apollo/client/masking"; +import type { FetchResult } from "@apollo/client/link/core"; +import type { Masked } from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react/context"; import { useMutation, useQuery } from "@apollo/client/react/hooks"; +import type { MockedResponse } from "@apollo/client/testing"; import { - MockedResponse, MockLink, mockSingleLink, MockSubscriptionLink, } from "@apollo/client/testing"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; import { invariant } from "@apollo/client/utilities/invariant"; -import { spyOnConsole } from "../../../testing/internal/index.js"; - const IS_REACT_17 = React.version.startsWith("17"); const IS_REACT_18 = React.version.startsWith("18"); const IS_REACT_19 = React.version.startsWith("19"); diff --git a/src/react/hooks/__tests__/useQuery.test.tsx b/src/react/hooks/__tests__/useQuery.test.tsx index 8b00eb05fd8..02a38eacbd6 100644 --- a/src/react/hooks/__tests__/useQuery.test.tsx +++ b/src/react/hooks/__tests__/useQuery.test.tsx @@ -11,47 +11,52 @@ import { renderHookToSnapshotStream, } from "@testing-library/react-render-stream"; import { userEvent } from "@testing-library/user-event"; -import { DocumentNode, GraphQLError, GraphQLFormattedError } from "graphql"; +import type { DocumentNode, GraphQLFormattedError } from "graphql"; +import { GraphQLError } from "graphql"; import { gql } from "graphql-tag"; -import React, { Fragment, ReactNode, useEffect, useState } from "react"; +import type { ReactNode } from "react"; +import React, { Fragment, useEffect, useState } from "react"; import { asapScheduler, Observable, observeOn, of } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { - ApolloClient, - CombinedGraphQLErrors, +import type { FetchPolicy, - NetworkStatus, OperationVariables, TypedDocumentNode, WatchQueryFetchPolicy, WatchQueryOptions, } from "@apollo/client/core"; +import { + ApolloClient, + CombinedGraphQLErrors, + NetworkStatus, +} from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; -import { Unmasked } from "@apollo/client/masking"; +import type { Unmasked } from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react/context"; import { useLazyQuery, useMutation, useQuery, } from "@apollo/client/react/hooks"; +import type { MockedResponse } from "@apollo/client/testing"; import { - MockedResponse, MockLink, mockSingleLink, MockSubscriptionLink, tick, wait, } from "@apollo/client/testing"; -import { MockedProvider } from "@apollo/client/testing/react"; -import { concatPagination, Reference } from "@apollo/client/utilities"; -import { InvariantError } from "@apollo/client/utilities/invariant"; - -import { mockFetchQuery } from "../../../core/__tests__/ObservableQuery.js"; import { setupPaginatedCase, spyOnConsole, -} from "../../../testing/internal/index.js"; +} from "@apollo/client/testing/internal"; +import { MockedProvider } from "@apollo/client/testing/react"; +import type { Reference } from "@apollo/client/utilities"; +import { concatPagination } from "@apollo/client/utilities"; +import { InvariantError } from "@apollo/client/utilities/invariant"; + +import type { QueryManager } from "../../../core/QueryManager.js"; const IS_REACT_17 = React.version.startsWith("17"); const IS_REACT_18 = React.version.startsWith("18"); @@ -7384,14 +7389,19 @@ describe("useQuery Hook", () => { link, }); - const mocks = mockFetchQuery(client["queryManager"]); + const fetchQueryByPolicy = jest.spyOn( + client["queryManager"] as any as { + fetchQueryByPolicy: QueryManager["fetchQueryByPolicy"]; + }, + "fetchQueryByPolicy" + ); const expectQueryTriggered = ( nth: number, fetchPolicy: WatchQueryFetchPolicy ) => { - expect(mocks.fetchQueryByPolicy).toHaveBeenCalledTimes(nth); - expect(mocks.fetchQueryByPolicy).toHaveBeenNthCalledWith( + expect(fetchQueryByPolicy).toHaveBeenCalledTimes(nth); + expect(fetchQueryByPolicy).toHaveBeenNthCalledWith( nth, expect.anything(), expect.objectContaining({ fetchPolicy }), diff --git a/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx b/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx index eb9c8a95c7f..631332b2318 100644 --- a/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx +++ b/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx @@ -7,13 +7,13 @@ import { import { userEvent } from "@testing-library/user-event"; import React, { Suspense } from "react"; +import type { TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient, gql, InMemoryCache, NetworkStatus, split, - TypedDocumentNode, } from "@apollo/client/core"; import { createQueryPreloader } from "@apollo/client/react"; import { @@ -22,25 +22,24 @@ import { useQueryRefHandlers, useReadQuery, } from "@apollo/client/react/hooks"; -import { QueryRef } from "@apollo/client/react/internal"; +import type { QueryRef } from "@apollo/client/react/internal"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink } from "@apollo/client/testing"; +import type { + PaginatedCaseData, + SimpleCaseData, +} from "@apollo/client/testing/internal"; import { - MockedResponse, - MockLink, - MockSubscriptionLink, -} from "@apollo/client/testing"; + createClientWrapper, + setupPaginatedCase, + setupSimpleCase, +} from "@apollo/client/testing/internal"; import { concatPagination, getMainDefinition } from "@apollo/client/utilities"; -import { +import type { SubscribeToMoreFunction, SubscribeToMoreUpdateQueryFn, } from "../../../core/watchQueryOptions.js"; -import { - createClientWrapper, - PaginatedCaseData, - setupPaginatedCase, - setupSimpleCase, - SimpleCaseData, -} from "../../../testing/internal/index.js"; test("does not interfere with updates from useReadQuery", async () => { const { query, mocks } = setupSimpleCase(); diff --git a/src/react/hooks/__tests__/useSubscription.test.tsx b/src/react/hooks/__tests__/useSubscription.test.tsx index 7f2cb599a6e..cc4487cb82f 100644 --- a/src/react/hooks/__tests__/useSubscription.test.tsx +++ b/src/react/hooks/__tests__/useSubscription.test.tsx @@ -4,30 +4,26 @@ import { renderHookToSnapshotStream, } from "@testing-library/react-render-stream"; import { expectTypeOf } from "expect-type"; -import { GraphQLFormattedError } from "graphql"; +import type { GraphQLFormattedError } from "graphql"; import { gql } from "graphql-tag"; import React from "react"; import { ErrorBoundary } from "react-error-boundary"; import { InMemoryCache as Cache } from "@apollo/client/cache"; -import { - ApolloClient, - ApolloLink, - concat, - TypedDocumentNode, -} from "@apollo/client/core"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { ApolloClient, ApolloLink, concat } from "@apollo/client/core"; import { CombinedGraphQLErrors, CombinedProtocolErrors, } from "@apollo/client/errors"; -import { Masked, MaskedDocumentNode } from "@apollo/client/masking"; +import type { Masked, MaskedDocumentNode } from "@apollo/client/masking"; import { ApolloProvider } from "@apollo/client/react/context"; import { useSubscription } from "@apollo/client/react/hooks"; import { MockSubscriptionLink, tick, wait } from "@apollo/client/testing"; +import { mockMultipartSubscriptionStream } from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { MockedSubscriptionResult } from "../../../testing/core/mocking/mockSubscriptionLink.js"; -import { mockMultipartSubscriptionStream } from "../../../testing/internal/index.js"; +import type { MockedSubscriptionResult } from "../../../testing/core/mocking/mockSubscriptionLink.js"; const IS_REACT_17 = React.version.startsWith("17"); diff --git a/src/react/hooks/__tests__/useSuspenseFragment.test.tsx b/src/react/hooks/__tests__/useSuspenseFragment.test.tsx index 6dd1d4ab735..d64df730cbe 100644 --- a/src/react/hooks/__tests__/useSuspenseFragment.test.tsx +++ b/src/react/hooks/__tests__/useSuspenseFragment.test.tsx @@ -9,25 +9,22 @@ import { userEvent } from "@testing-library/user-event"; import { expectTypeOf } from "expect-type"; import React, { Suspense } from "react"; -import { - ApolloClient, +import type { FragmentType, - gql, - InMemoryCache, Masked, MaskedDocumentNode, MaybeMasked, OperationVariables, TypedDocumentNode, } from "@apollo/client/core"; +import { ApolloClient, gql, InMemoryCache } from "@apollo/client/core"; import { ApolloProvider } from "@apollo/client/react/context"; import { useSuspenseFragment } from "@apollo/client/react/hooks"; import { MockSubscriptionLink, wait } from "@apollo/client/testing"; +import { renderAsync, spyOnConsole } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { renderAsync, spyOnConsole } from "../../../testing/internal/index.js"; - function createDefaultRenderStream() { return createRenderStream({ initialSnapshot: { diff --git a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx index d34d0c548c7..125ac8eae51 100644 --- a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx +++ b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx @@ -1,10 +1,5 @@ -import { - act, - renderHook, - RenderHookOptions, - screen, - waitFor, -} from "@testing-library/react"; +import type { RenderHookOptions } from "@testing-library/react"; +import { act, renderHook, screen, waitFor } from "@testing-library/react"; import { createRenderStream, disableActEnvironment, @@ -15,57 +10,63 @@ import { equal } from "@wry/equality"; import { expectTypeOf } from "expect-type"; import { GraphQLError } from "graphql"; import React, { Fragment, StrictMode, Suspense, useTransition } from "react"; -import { ErrorBoundary, FallbackProps } from "react-error-boundary"; +import type { FallbackProps } from "react-error-boundary"; +import { ErrorBoundary } from "react-error-boundary"; import { Observable, of } from "rxjs"; -import { +import type { ApolloCache, + DocumentNode, + ErrorPolicy, + OperationVariables, + QueryResult, + SubscribeToMoreOptions, + TypedDocumentNode, +} from "@apollo/client/core"; +import { ApolloClient, ApolloLink, CombinedGraphQLErrors, - DocumentNode, - ErrorPolicy, gql, InMemoryCache, NetworkStatus, - OperationVariables, - QueryResult, split, - SubscribeToMoreOptions, - TypedDocumentNode, } from "@apollo/client/core"; -import { Masked, MaskedDocumentNode, Unmasked } from "@apollo/client/masking"; +import type { + Masked, + MaskedDocumentNode, + Unmasked, +} from "@apollo/client/masking"; import { skipToken } from "@apollo/client/react"; import { ApolloProvider } from "@apollo/client/react/context"; import { useSuspenseQuery } from "@apollo/client/react/hooks"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink } from "@apollo/client/testing"; +import type { + PaginatedCaseData, + PaginatedCaseVariables, +} from "@apollo/client/testing/internal"; import { - MockedResponse, - MockLink, - MockSubscriptionLink, -} from "@apollo/client/testing"; + actAsync, + renderAsync, + renderHookAsync, + setupPaginatedCase, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; +import type { DeepPartial } from "@apollo/client/utilities"; import { compact, concatPagination, - DeepPartial, getMainDefinition, offsetLimitPagination, } from "@apollo/client/utilities"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { +import type { RefetchWritePolicy, WatchQueryFetchPolicy, } from "../../../core/watchQueryOptions.js"; -import { - actAsync, - PaginatedCaseData, - PaginatedCaseVariables, - renderAsync, - renderHookAsync, - setupPaginatedCase, - spyOnConsole, -} from "../../../testing/internal/index.js"; const IS_REACT_19 = React.version.startsWith("19"); diff --git a/src/react/hooks/internal/__tests__/useDeepMemo.test.ts b/src/react/hooks/internal/__tests__/useDeepMemo.test.ts index cb95af88e41..fb19c4e444e 100644 --- a/src/react/hooks/internal/__tests__/useDeepMemo.test.ts +++ b/src/react/hooks/internal/__tests__/useDeepMemo.test.ts @@ -1,5 +1,7 @@ import { renderHook } from "@testing-library/react"; +//not exported +// eslint-disable-next-line local-rules/no-relative-imports import { useDeepMemo } from "../useDeepMemo.js"; describe("useDeepMemo", () => { diff --git a/src/react/hooks/internal/__tests__/useRenderGuard.test.tsx b/src/react/hooks/internal/__tests__/useRenderGuard.test.tsx index 11b45c8b85b..411577ed2dd 100644 --- a/src/react/hooks/internal/__tests__/useRenderGuard.test.tsx +++ b/src/react/hooks/internal/__tests__/useRenderGuard.test.tsx @@ -2,6 +2,8 @@ import { render, waitFor } from "@testing-library/react"; import * as React from "react"; +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import { useRenderGuard } from "../useRenderGuard.js"; const UNDEF = {}; diff --git a/src/react/internal/cache/__tests__/QueryReference.test.tsx b/src/react/internal/cache/__tests__/QueryReference.test.tsx index a846e749fda..c368e9f3cf3 100644 --- a/src/react/internal/cache/__tests__/QueryReference.test.tsx +++ b/src/react/internal/cache/__tests__/QueryReference.test.tsx @@ -3,9 +3,9 @@ import { of } from "rxjs"; import { ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client/core"; import { InternalQueryReference } from "@apollo/client/react/internal"; +import { setupSimpleCase } from "@apollo/client/testing/internal"; -import { setupSimpleCase } from "../../../../testing/internal/index.js"; -import { +import type { PreloadedQueryRef, QueryRef, QueryReference, diff --git a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx index 1c794a86277..494ceb7e2f9 100644 --- a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx +++ b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx @@ -11,6 +11,10 @@ import React, { Suspense } from "react"; import { ErrorBoundary } from "react-error-boundary"; import { Observable } from "rxjs"; +import type { + OperationVariables, + TypedDocumentNode, +} from "@apollo/client/core"; import { ApolloClient, ApolloLink, @@ -18,39 +22,32 @@ import { gql, InMemoryCache, NetworkStatus, - OperationVariables, - TypedDocumentNode, } from "@apollo/client/core"; -import { Masked } from "@apollo/client/masking"; +import type { Masked } from "@apollo/client/masking"; import { createQueryPreloader } from "@apollo/client/react"; import { ApolloProvider } from "@apollo/client/react/context"; import { useReadQuery } from "@apollo/client/react/hooks"; -import { +import type { PreloadedQueryRef, QueryRef, - unwrapQueryRef, } from "@apollo/client/react/internal"; -import { - MockedResponse, - MockLink, - MockSubscriptionLink, - wait, -} from "@apollo/client/testing"; -import { DeepPartial } from "@apollo/client/utilities"; - +import { unwrapQueryRef } from "@apollo/client/react/internal"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink, wait } from "@apollo/client/testing"; +import type { + MaskedVariablesCaseData, + SimpleCaseData, + VariablesCaseData, +} from "@apollo/client/testing/internal"; import { createClientWrapper, renderHookAsync, + setupMaskedVariablesCase, setupSimpleCase, setupVariablesCase, - SimpleCaseData, spyOnConsole, - VariablesCaseData, -} from "../../../testing/internal/index.js"; -import { - MaskedVariablesCaseData, - setupMaskedVariablesCase, -} from "../../../testing/internal/scenarios/index.js"; +} from "@apollo/client/testing/internal"; +import type { DeepPartial } from "@apollo/client/utilities"; function createDefaultClient(mocks: MockedResponse[]) { return new ApolloClient({ diff --git a/src/react/ssr/__tests__/getDataFromTree.test.tsx b/src/react/ssr/__tests__/getDataFromTree.test.tsx index 1ad472f9b3d..db4d108d77d 100644 --- a/src/react/ssr/__tests__/getDataFromTree.test.tsx +++ b/src/react/ssr/__tests__/getDataFromTree.test.tsx @@ -1,14 +1,13 @@ +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import "../../../testing/internal/messageChannelPolyfill.js"; -import { DocumentNode } from "graphql"; +import type { DocumentNode } from "graphql"; import { gql } from "graphql-tag"; import React from "react"; import { InMemoryCache as Cache } from "@apollo/client/cache"; -import { - ApolloClient, - CombinedGraphQLErrors, - TypedDocumentNode, -} from "@apollo/client/core"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { ApolloClient, CombinedGraphQLErrors } from "@apollo/client/core"; import { ApolloProvider, getApolloContext } from "@apollo/client/react/context"; import { useQuery } from "@apollo/client/react/hooks"; import { getDataFromTree } from "@apollo/client/react/ssr"; diff --git a/src/react/ssr/__tests__/prerenderStatic.test.tsx b/src/react/ssr/__tests__/prerenderStatic.test.tsx index f14ddb062a2..2bab86fca45 100644 --- a/src/react/ssr/__tests__/prerenderStatic.test.tsx +++ b/src/react/ssr/__tests__/prerenderStatic.test.tsx @@ -1,4 +1,6 @@ /* eslint-disable testing-library/render-result-naming-convention */ +// not exported +// eslint-disable-next-line local-rules/no-relative-imports import "../../../testing/internal/messageChannelPolyfill.js"; import "./polyfillReactDomTypes.d.ts"; @@ -11,12 +13,12 @@ import { renderToStaticMarkup, renderToString } from "react-dom/server"; import { prerender } from "react-dom/static"; import { prerenderToNodeStream } from "react-dom/static.node"; +import type { TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient, ApolloLink, gql, InMemoryCache, - TypedDocumentNode, } from "@apollo/client/core"; import { ApolloProvider, @@ -25,16 +27,11 @@ import { useSuspenseQuery, } from "@apollo/client/react"; import { prerenderStatic } from "@apollo/client/react/ssr"; -import { - MockedResponse, - MockLink, - MockSubscriptionLink, - wait, -} from "@apollo/client/testing"; +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink, MockSubscriptionLink, wait } from "@apollo/client/testing"; +import { resetApolloContext } from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { resetApolloContext } from "../../../testing/internal/resetApolloContext.js"; - beforeEach(() => { // We are running tests with multiple different renderers, and that can result in a warning like // > Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported. diff --git a/src/react/ssr/__tests__/useQuery.test.tsx b/src/react/ssr/__tests__/useQuery.test.tsx index a6e2ace5ca2..2f2263ac8bc 100644 --- a/src/react/ssr/__tests__/useQuery.test.tsx +++ b/src/react/ssr/__tests__/useQuery.test.tsx @@ -4,18 +4,19 @@ import React from "react"; import { renderToStaticMarkup, renderToString } from "react-dom/server"; import { InMemoryCache } from "@apollo/client/cache"; -import { ApolloClient, TypedDocumentNode } from "@apollo/client/core"; +import type { TypedDocumentNode } from "@apollo/client/core"; +import { ApolloClient } from "@apollo/client/core"; import { ApolloProvider } from "@apollo/client/react/context"; import { useApolloClient, useQuery } from "@apollo/client/react/hooks"; import { prerenderStatic, renderToStringWithData, } from "@apollo/client/react/ssr"; -import { MockedResponse, mockSingleLink } from "@apollo/client/testing"; +import type { MockedResponse } from "@apollo/client/testing"; +import { mockSingleLink } from "@apollo/client/testing"; +import { resetApolloContext } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; -import { resetApolloContext } from "../../../testing/internal/resetApolloContext.js"; - beforeEach(() => { // We are running tests with multiple different renderers, and that can result in a warning like // > Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported. diff --git a/src/react/ssr/__tests__/useReactiveVar.test.tsx b/src/react/ssr/__tests__/useReactiveVar.test.tsx index b1d7fed6d92..c6b2528cae3 100644 --- a/src/react/ssr/__tests__/useReactiveVar.test.tsx +++ b/src/react/ssr/__tests__/useReactiveVar.test.tsx @@ -4,8 +4,7 @@ import React from "react"; import { makeVar } from "@apollo/client/core"; import { useReactiveVar } from "@apollo/client/react/hooks"; import { renderToStringWithData } from "@apollo/client/react/ssr"; - -import { spyOnConsole } from "../../../testing/internal/index.js"; +import { spyOnConsole } from "@apollo/client/testing/internal"; describe("useReactiveVar Hook SSR", () => { it("does not cause warnings", async () => { diff --git a/src/testing/core/mocking/__tests__/mockLink.ts b/src/testing/core/mocking/__tests__/mockLink.ts index 7bb6dd61eb5..cd58d993b1c 100644 --- a/src/testing/core/mocking/__tests__/mockLink.ts +++ b/src/testing/core/mocking/__tests__/mockLink.ts @@ -1,13 +1,13 @@ import { gql } from "graphql-tag"; import { execute } from "@apollo/client/link/core"; - +import type { MockedResponse } from "@apollo/client/testing"; +import { MockLink } from "@apollo/client/testing"; import { enableFakeTimers, ObservableStream, spyOnConsole, -} from "../../../internal/index.js"; -import { MockedResponse, MockLink } from "../mockLink.js"; +} from "@apollo/client/testing/internal"; describe("MockedResponse.newData", () => { const setup = () => { diff --git a/src/testing/experimental/__tests__/createTestSchema.test.tsx b/src/testing/experimental/__tests__/createTestSchema.test.tsx index 29a154e5f24..1baad944581 100644 --- a/src/testing/experimental/__tests__/createTestSchema.test.tsx +++ b/src/testing/experimental/__tests__/createTestSchema.test.tsx @@ -1,16 +1,14 @@ import { screen } from "@testing-library/react"; +import type { RenderStream } from "@testing-library/react-render-stream"; import { createRenderStream, disableActEnvironment, - RenderStream, } from "@testing-library/react-render-stream"; import { userEvent } from "@testing-library/user-event"; import { buildSchema } from "graphql"; import * as React from "react"; -import { - ErrorBoundary as ReactErrorBoundary, - FallbackProps, -} from "react-error-boundary"; +import type { FallbackProps } from "react-error-boundary"; +import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary"; import type { TypedDocumentNode } from "@apollo/client/core"; import { @@ -21,12 +19,16 @@ import { } from "@apollo/client/core"; import type { UseSuspenseQueryResult } from "@apollo/client/react"; import { useMutation, useSuspenseQuery } from "@apollo/client/react"; +import { + createSchemaFetch, + createTestSchema, +} from "@apollo/client/testing/experimental"; +import { + createClientWrapper, + spyOnConsole, +} from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; -import { createClientWrapper, spyOnConsole } from "../../internal/index.js"; -import { createSchemaFetch } from "../createSchemaFetch.js"; -import { createTestSchema } from "../createTestSchema.js"; - const IS_REACT_19 = React.version.startsWith("19"); const typeDefs = /* GraphQL */ ` diff --git a/src/testing/experimental/createSchemaFetch.ts b/src/testing/experimental/createSchemaFetch.ts index e494d93f7ed..1421c8644f7 100644 --- a/src/testing/experimental/createSchemaFetch.ts +++ b/src/testing/experimental/createSchemaFetch.ts @@ -3,8 +3,7 @@ import { execute, GraphQLError, validate } from "graphql"; import { gql } from "@apollo/client/core"; import { wait } from "@apollo/client/testing"; - -import { withCleanup } from "../internal/index.js"; +import { withCleanup } from "@apollo/client/testing/internal"; /** * A function that accepts a static `schema` and a `mockFetchOpts` object and diff --git a/src/testing/internal/__tests__/ObservableStream.test.ts b/src/testing/internal/__tests__/ObservableStream.test.ts index 2add7918ec5..54348b547e2 100644 --- a/src/testing/internal/__tests__/ObservableStream.test.ts +++ b/src/testing/internal/__tests__/ObservableStream.test.ts @@ -1,6 +1,6 @@ import { Observable } from "rxjs"; -import { ObservableStream } from "../ObservableStream.js"; +import { ObservableStream } from "@apollo/client/testing/internal"; it("allows to step through an observable until completion", async () => { const stream = new ObservableStream( diff --git a/src/testing/internal/disposables/__tests__/spyOnConsole.test.ts b/src/testing/internal/disposables/__tests__/spyOnConsole.test.ts index 44a356b9ac6..6ecf23780ba 100644 --- a/src/testing/internal/disposables/__tests__/spyOnConsole.test.ts +++ b/src/testing/internal/disposables/__tests__/spyOnConsole.test.ts @@ -1,4 +1,4 @@ -import { spyOnConsole } from "../index.js"; +import { spyOnConsole } from "@apollo/client/testing/internal"; const originalLog = console.log; const originalWarn = console.warn; diff --git a/src/testing/internal/disposables/__tests__/withCleanup.test.ts b/src/testing/internal/disposables/__tests__/withCleanup.test.ts index dc7fa965754..5a1ac8eedf0 100644 --- a/src/testing/internal/disposables/__tests__/withCleanup.test.ts +++ b/src/testing/internal/disposables/__tests__/withCleanup.test.ts @@ -1,4 +1,4 @@ -import { withCleanup } from "../index.js"; +import { withCleanup } from "@apollo/client/testing/internal"; describe("withCleanup", () => { it("calls cleanup", () => { let cleanedUp = false; diff --git a/src/testing/internal/disposables/spyOnConsole.ts b/src/testing/internal/disposables/spyOnConsole.ts index 143de49fd7c..152d7ef404b 100644 --- a/src/testing/internal/disposables/spyOnConsole.ts +++ b/src/testing/internal/disposables/spyOnConsole.ts @@ -10,7 +10,6 @@ type Spies = Record< jest.SpyInstance >; -/** @internal */ export function spyOnConsole( ...spyOn: Keys ): Spies & Disposable { diff --git a/src/testing/internal/index.ts b/src/testing/internal/index.ts index f38c071cf10..5851ff32860 100644 --- a/src/testing/internal/index.ts +++ b/src/testing/internal/index.ts @@ -7,6 +7,7 @@ export { export { ObservableStream } from "./ObservableStream.js"; export type { + MaskedVariablesCaseData, PaginatedCaseData, PaginatedCaseVariables, SimpleCaseData, @@ -15,6 +16,7 @@ export type { } from "./scenarios/index.js"; export { addDelayToMocks, + setupMaskedVariablesCase, setupPaginatedCase, setupSimpleCase, setupVariablesCase, diff --git a/src/testing/matchers/toComplete.ts b/src/testing/matchers/toComplete.ts index e7fc6118ec9..15503fee9ad 100644 --- a/src/testing/matchers/toComplete.ts +++ b/src/testing/matchers/toComplete.ts @@ -1,6 +1,7 @@ import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toComplete: MatcherFunction<[options?: TakeOptions]> = diff --git a/src/testing/matchers/toEmitAnything.ts b/src/testing/matchers/toEmitAnything.ts index 1676b4c4b64..7761449ae41 100644 --- a/src/testing/matchers/toEmitAnything.ts +++ b/src/testing/matchers/toEmitAnything.ts @@ -1,6 +1,7 @@ import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitAnything: MatcherFunction<[options?: TakeOptions]> = diff --git a/src/testing/matchers/toEmitApolloQueryResult.ts b/src/testing/matchers/toEmitApolloQueryResult.ts index 905472e481a..6675a7d7f6d 100644 --- a/src/testing/matchers/toEmitApolloQueryResult.ts +++ b/src/testing/matchers/toEmitApolloQueryResult.ts @@ -2,8 +2,8 @@ import { iterableEquality } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; import type { ApolloQueryResult } from "@apollo/client/core"; +import type { ObservableStream } from "@apollo/client/testing/internal"; -import type { ObservableStream } from "../internal/index.js"; import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitApolloQueryResult: MatcherFunction< diff --git a/src/testing/matchers/toEmitError.ts b/src/testing/matchers/toEmitError.ts index 7c915149753..da44274e045 100644 --- a/src/testing/matchers/toEmitError.ts +++ b/src/testing/matchers/toEmitError.ts @@ -1,6 +1,7 @@ import type { MatcherContext, MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; function isErrorEqual(this: MatcherContext, expected: any, actual: any) { diff --git a/src/testing/matchers/toEmitFetchResult.ts b/src/testing/matchers/toEmitFetchResult.ts index af1e4f5d82e..cf4bc05d237 100644 --- a/src/testing/matchers/toEmitFetchResult.ts +++ b/src/testing/matchers/toEmitFetchResult.ts @@ -2,8 +2,8 @@ import { iterableEquality } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; import type { FetchResult } from "@apollo/client/core"; +import type { ObservableStream } from "@apollo/client/testing/internal"; -import type { ObservableStream } from "../internal/index.js"; import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitFetchResult: MatcherFunction< diff --git a/src/testing/matchers/toEmitMatchedValue.ts b/src/testing/matchers/toEmitMatchedValue.ts index 01dce8db893..aa19f19d784 100644 --- a/src/testing/matchers/toEmitMatchedValue.ts +++ b/src/testing/matchers/toEmitMatchedValue.ts @@ -5,7 +5,8 @@ import { } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitMatchedValue: MatcherFunction< diff --git a/src/testing/matchers/toEmitNext.ts b/src/testing/matchers/toEmitNext.ts index 7d51cf28004..37b591dba8a 100644 --- a/src/testing/matchers/toEmitNext.ts +++ b/src/testing/matchers/toEmitNext.ts @@ -1,6 +1,7 @@ import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitNext: MatcherFunction<[options?: TakeOptions]> = diff --git a/src/testing/matchers/toEmitStrictTyped.ts b/src/testing/matchers/toEmitStrictTyped.ts index 21a214a9ae7..8b8218e7a39 100644 --- a/src/testing/matchers/toEmitStrictTyped.ts +++ b/src/testing/matchers/toEmitStrictTyped.ts @@ -1,7 +1,8 @@ import { iterableEquality } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; import { getSerializableProperties } from "./utils/getSerializableProperties.js"; diff --git a/src/testing/matchers/toEmitValue.ts b/src/testing/matchers/toEmitValue.ts index 2443116975f..e59760b9d1b 100644 --- a/src/testing/matchers/toEmitValue.ts +++ b/src/testing/matchers/toEmitValue.ts @@ -1,7 +1,8 @@ import { iterableEquality } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitValue: MatcherFunction<[value: any, options?: TakeOptions]> = diff --git a/src/testing/matchers/toEmitValueStrict.ts b/src/testing/matchers/toEmitValueStrict.ts index 6a639f5b37e..250ac947d7e 100644 --- a/src/testing/matchers/toEmitValueStrict.ts +++ b/src/testing/matchers/toEmitValueStrict.ts @@ -6,7 +6,8 @@ import { } from "@jest/expect-utils"; import type { MatcherFunction } from "expect"; -import type { ObservableStream } from "../internal/index.js"; +import type { ObservableStream } from "@apollo/client/testing/internal"; + import type { TakeOptions } from "../internal/ObservableStream.js"; export const toEmitValueStrict: MatcherFunction< diff --git a/src/testing/react/__tests__/MockedProvider.test.tsx b/src/testing/react/__tests__/MockedProvider.test.tsx index ef77da7f618..ef0559848a2 100644 --- a/src/testing/react/__tests__/MockedProvider.test.tsx +++ b/src/testing/react/__tests__/MockedProvider.test.tsx @@ -1,15 +1,16 @@ import { act, render, screen, waitFor } from "@testing-library/react"; -import { DocumentNode } from "graphql"; +import type { DocumentNode } from "graphql"; import { gql } from "graphql-tag"; import React from "react"; -import { Observable } from "rxjs"; +import type { Observable } from "rxjs"; import { InMemoryCache } from "@apollo/client/cache"; -import { ApolloLink, FetchResult } from "@apollo/client/link/core"; +import type { FetchResult } from "@apollo/client/link/core"; +import { ApolloLink } from "@apollo/client/link/core"; import { useQuery } from "@apollo/client/react"; -import { MockedResponse, MockLink } from "@apollo/client/testing/core"; - -import { MockedProvider } from "../MockedProvider.js"; +import type { MockedResponse } from "@apollo/client/testing/core"; +import { MockLink } from "@apollo/client/testing/core"; +import { MockedProvider } from "@apollo/client/testing/react"; const variables = { username: "mock_username", diff --git a/src/utilities/caching/__tests__/getMemoryInternals.ts b/src/utilities/caching/__tests__/getMemoryInternals.ts index fc82f5b02db..03900b5ad18 100644 --- a/src/utilities/caching/__tests__/getMemoryInternals.ts +++ b/src/utilities/caching/__tests__/getMemoryInternals.ts @@ -10,11 +10,12 @@ import { } from "@apollo/client/core"; import { createPersistedQueryLink } from "@apollo/client/link/persisted-queries"; import { removeTypenameFromVariables } from "@apollo/client/link/remove-typename"; - // importing react so the `parser` cache initializes import "@apollo/client/react"; import { cacheSizes } from "@apollo/client/utilities"; +// this is compiled away so we need to import it from sources +// eslint-disable-next-line local-rules/no-relative-imports import { defaultCacheSizes } from "../sizes.js"; function sha256(data: string) { diff --git a/src/utilities/graphql/__tests__/DocumentTransform.ts b/src/utilities/graphql/__tests__/DocumentTransform.ts index 815d96be7eb..eb87dc954bb 100644 --- a/src/utilities/graphql/__tests__/DocumentTransform.ts +++ b/src/utilities/graphql/__tests__/DocumentTransform.ts @@ -1,4 +1,5 @@ -import { DocumentNode, Kind, visit } from "graphql"; +import type { DocumentNode } from "graphql"; +import { Kind, visit } from "graphql"; import { gql } from "graphql-tag"; import { diff --git a/src/utilities/graphql/__tests__/directives.ts b/src/utilities/graphql/__tests__/directives.ts index cbd677a67d5..bcc73b8c641 100644 --- a/src/utilities/graphql/__tests__/directives.ts +++ b/src/utilities/graphql/__tests__/directives.ts @@ -3,6 +3,7 @@ import { BREAK, visit } from "graphql"; import { gql } from "graphql-tag"; import { cloneDeep } from "lodash"; +import { spyOnConsole } from "@apollo/client/testing/internal"; import { getFragmentMaskMode, getQueryDefinition, @@ -12,8 +13,6 @@ import { shouldInclude, } from "@apollo/client/utilities"; -import { spyOnConsole } from "../../../testing/internal/index.js"; - describe("hasDirectives", () => { it("should allow searching the ast for a directive", () => { const query = gql` diff --git a/src/utilities/graphql/__tests__/fragments.ts b/src/utilities/graphql/__tests__/fragments.ts index a691045aa8a..060fc125256 100644 --- a/src/utilities/graphql/__tests__/fragments.ts +++ b/src/utilities/graphql/__tests__/fragments.ts @@ -10,7 +10,7 @@ import { getFragmentQueryDocument, } from "@apollo/client/utilities"; -import { FragmentMap } from "../fragments.js"; +import type { FragmentMap } from "../fragments.js"; describe("getFragmentQueryDocument", () => { it("will throw an error if there is an operation", () => { diff --git a/src/utilities/graphql/__tests__/getFromAST.ts b/src/utilities/graphql/__tests__/getFromAST.ts index 0168d9c51a4..bd1204a038d 100644 --- a/src/utilities/graphql/__tests__/getFromAST.ts +++ b/src/utilities/graphql/__tests__/getFromAST.ts @@ -1,8 +1,5 @@ -import { - FragmentDefinitionNode, - OperationDefinitionNode, - print, -} from "graphql"; +import type { FragmentDefinitionNode, OperationDefinitionNode } from "graphql"; +import { print } from "graphql"; import { gql } from "graphql-tag"; import { diff --git a/src/utilities/graphql/__tests__/transform.ts b/src/utilities/graphql/__tests__/transform.ts index 0fc2887937d..3aa51241f68 100644 --- a/src/utilities/graphql/__tests__/transform.ts +++ b/src/utilities/graphql/__tests__/transform.ts @@ -1,4 +1,5 @@ -import { DocumentNode, Kind, print } from "graphql"; +import type { DocumentNode } from "graphql"; +import { Kind, print } from "graphql"; import { disableFragmentWarnings, gql } from "graphql-tag"; // Turn off warnings for repeated fragment names diff --git a/src/utilities/invariant/__tests__/invariant.test.ts b/src/utilities/invariant/__tests__/invariant.test.ts index 793b8ee70c8..434cd9f412f 100644 --- a/src/utilities/invariant/__tests__/invariant.test.ts +++ b/src/utilities/invariant/__tests__/invariant.test.ts @@ -1,11 +1,10 @@ +import { spyOnConsole } from "@apollo/client/testing/internal"; import { ApolloErrorMessageHandler, invariant, InvariantError, } from "@apollo/client/utilities/invariant"; -import { spyOnConsole } from "../../../testing/internal/index.js"; - function withDev(): typeof import("../../../dev/index.js") & AsyncDisposable { const originalErrorMessageHandler = window[ApolloErrorMessageHandler]; window[ApolloErrorMessageHandler] = undefined; diff --git a/src/utilities/policies/__tests__/relayStylePagination.test.ts b/src/utilities/policies/__tests__/relayStylePagination.test.ts index f8f6b645345..54be5928301 100644 --- a/src/utilities/policies/__tests__/relayStylePagination.test.ts +++ b/src/utilities/policies/__tests__/relayStylePagination.test.ts @@ -1,13 +1,12 @@ +import type { FieldFunctionOptions, StoreObject } from "@apollo/client/cache"; import { - FieldFunctionOptions, InMemoryCache, isReference, makeReference, - StoreObject, } from "@apollo/client/cache"; import { relayStylePagination } from "@apollo/client/utilities"; -import { TRelayPageInfo } from "../pagination.js"; +import type { TRelayPageInfo } from "../pagination.js"; describe("relayStylePagination", () => { const policy = relayStylePagination();