From 04132af121c9b48d6e03eb733b9b91f825defbac Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 9 Apr 2024 22:56:10 -0600 Subject: [PATCH 1/3] Fix network request when using skip/skipToken with useSuspenseQuery in strict mode (#11769) --- .changeset/thick-buttons-juggle.md | 5 + .size-limits.json | 4 +- .../__tests__/useBackgroundQuery.test.tsx | 186 ++++++++++++++++++ .../hooks/__tests__/useSuspenseQuery.test.tsx | 94 +++++++++ src/react/internal/cache/QueryReference.ts | 10 +- 5 files changed, 293 insertions(+), 6 deletions(-) create mode 100644 .changeset/thick-buttons-juggle.md diff --git a/.changeset/thick-buttons-juggle.md b/.changeset/thick-buttons-juggle.md new file mode 100644 index 00000000000..6208d80fdb6 --- /dev/null +++ b/.changeset/thick-buttons-juggle.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +Fix an issue where using `skipToken` or the `skip` option with `useSuspenseQuery` in React's strict mode would perform a network request. diff --git a/.size-limits.json b/.size-limits.json index 69a2f58b769..b33df04bf24 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -1,4 +1,4 @@ { - "dist/apollo-client.min.cjs": 39368, - "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32634 + "dist/apollo-client.min.cjs": 39373, + "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32636 } diff --git a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx index 11acab50152..605c5ed42c1 100644 --- a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx +++ b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx @@ -2100,6 +2100,192 @@ it("does not make network requests when `skipToken` is used", async () => { } }); +it("does not make network requests when `skipToken` is used in strict mode", async () => { + const { query, mocks } = setupSimpleCase(); + const Profiler = createDefaultProfiler(); + const { SuspenseFallback, ReadQueryHook } = + createDefaultTrackedComponents(Profiler); + const user = userEvent.setup(); + + let fetchCount = 0; + + const link = new ApolloLink((operation) => { + return new Observable((observer) => { + fetchCount++; + + const mock = mocks.find(({ request }) => + equal(request.query, operation.query) + ); + + if (!mock) { + throw new Error("Could not find mock for operation"); + } + + observer.next((mock as any).result); + observer.complete(); + }); + }); + + const client = new ApolloClient({ + link, + cache: new InMemoryCache(), + }); + + function App() { + useTrackRenders(); + const [skip, setSkip] = React.useState(true); + const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined); + + return ( + <> + + }> + {queryRef && } + + + ); + } + + renderWithClient(, { + client, + wrapper: ({ children }) => ( + + {children} + + ), + }); + + // initial skipped result + await Profiler.takeRender(); + expect(fetchCount).toBe(0); + + // Toggle skip to `false` + await act(() => user.click(screen.getByText("Toggle skip"))); + await Profiler.takeRender(); + + { + const { snapshot } = await Profiler.takeRender(); + + expect(snapshot.result).toEqual({ + data: { greeting: "Hello" }, + error: undefined, + networkStatus: NetworkStatus.ready, + }); + } + + expect(fetchCount).toBe(1); + + // Toggle skip to `true` + await act(() => user.click(screen.getByText("Toggle skip"))); + + { + const { snapshot } = await Profiler.takeRender(); + + expect(snapshot.result).toEqual({ + data: { greeting: "Hello" }, + error: undefined, + networkStatus: NetworkStatus.ready, + }); + } + + expect(fetchCount).toBe(1); + + await expect(Profiler).not.toRerender(); +}); + +it("does not make network requests when using `skip` option in strict mode", async () => { + const { query, mocks } = setupSimpleCase(); + const Profiler = createDefaultProfiler(); + const { SuspenseFallback, ReadQueryHook } = + createDefaultTrackedComponents(Profiler); + const user = userEvent.setup(); + + let fetchCount = 0; + + const link = new ApolloLink((operation) => { + return new Observable((observer) => { + fetchCount++; + + const mock = mocks.find(({ request }) => + equal(request.query, operation.query) + ); + + if (!mock) { + throw new Error("Could not find mock for operation"); + } + + observer.next((mock as any).result); + observer.complete(); + }); + }); + + const client = new ApolloClient({ + link, + cache: new InMemoryCache(), + }); + + function App() { + useTrackRenders(); + const [skip, setSkip] = React.useState(true); + const [queryRef] = useBackgroundQuery(query, { skip }); + + return ( + <> + + }> + {queryRef && } + + + ); + } + + renderWithClient(, { + client, + wrapper: ({ children }) => ( + + {children} + + ), + }); + + // initial skipped result + await Profiler.takeRender(); + expect(fetchCount).toBe(0); + + // Toggle skip to `false` + await act(() => user.click(screen.getByText("Toggle skip"))); + await Profiler.takeRender(); + + { + const { snapshot } = await Profiler.takeRender(); + + expect(snapshot.result).toEqual({ + data: { greeting: "Hello" }, + error: undefined, + networkStatus: NetworkStatus.ready, + }); + } + + expect(fetchCount).toBe(1); + + // Toggle skip to `true` + await act(() => user.click(screen.getByText("Toggle skip"))); + + { + const { snapshot } = await Profiler.takeRender(); + + expect(snapshot.result).toEqual({ + data: { greeting: "Hello" }, + error: undefined, + networkStatus: NetworkStatus.ready, + }); + } + + expect(fetchCount).toBe(1); + + await expect(Profiler).not.toRerender(); +}); + it("result is referentially stable", async () => { const { query, mocks } = setupSimpleCase(); diff --git a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx index 9fbbc524521..121ae749493 100644 --- a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx +++ b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx @@ -5560,6 +5560,100 @@ describe("useSuspenseQuery", () => { expect(fetchCount).toBe(1); }); + // https://github.com/apollographql/apollo-client/issues/11768 + it("does not make network requests when using `skipToken` with strict mode", async () => { + const { query, mocks } = useVariablesQueryCase(); + + let fetchCount = 0; + + const link = new ApolloLink((operation) => { + return new Observable((observer) => { + fetchCount++; + + const mock = mocks.find(({ request }) => + equal(request.variables, operation.variables) + ); + + if (!mock) { + throw new Error("Could not find mock for operation"); + } + + observer.next(mock.result); + observer.complete(); + }); + }); + + const { result, rerender } = renderSuspenseHook( + ({ skip, id }) => + useSuspenseQuery(query, skip ? skipToken : { variables: { id } }), + { mocks, link, strictMode: true, initialProps: { skip: true, id: "1" } } + ); + + expect(fetchCount).toBe(0); + + rerender({ skip: false, id: "1" }); + + expect(fetchCount).toBe(1); + + await waitFor(() => { + expect(result.current).toMatchObject({ + ...mocks[0].result, + networkStatus: NetworkStatus.ready, + error: undefined, + }); + }); + + rerender({ skip: true, id: "2" }); + + expect(fetchCount).toBe(1); + }); + + it("does not make network requests when using `skip` with strict mode", async () => { + const { query, mocks } = useVariablesQueryCase(); + + let fetchCount = 0; + + const link = new ApolloLink((operation) => { + return new Observable((observer) => { + fetchCount++; + + const mock = mocks.find(({ request }) => + equal(request.variables, operation.variables) + ); + + if (!mock) { + throw new Error("Could not find mock for operation"); + } + + observer.next(mock.result); + observer.complete(); + }); + }); + + const { result, rerender } = renderSuspenseHook( + ({ skip, id }) => useSuspenseQuery(query, { skip, variables: { id } }), + { mocks, link, strictMode: true, initialProps: { skip: true, id: "1" } } + ); + + expect(fetchCount).toBe(0); + + rerender({ skip: false, id: "1" }); + + expect(fetchCount).toBe(1); + + await waitFor(() => { + expect(result.current).toMatchObject({ + ...mocks[0].result, + networkStatus: NetworkStatus.ready, + error: undefined, + }); + }); + + rerender({ skip: true, id: "2" }); + + expect(fetchCount).toBe(1); + }); + it("`skip` result is referentially stable", async () => { const { query, mocks } = useSimpleQueryCase(); diff --git a/src/react/internal/cache/QueryReference.ts b/src/react/internal/cache/QueryReference.ts index 7645ef0d6f0..148dcc250e8 100644 --- a/src/react/internal/cache/QueryReference.ts +++ b/src/react/internal/cache/QueryReference.ts @@ -207,18 +207,20 @@ export class InternalQueryReference { const { observable } = this; const originalFetchPolicy = this.watchQueryOptions.fetchPolicy; + const avoidNetworkRequests = + originalFetchPolicy === "no-cache" || originalFetchPolicy === "standby"; try { - if (originalFetchPolicy !== "no-cache") { + if (avoidNetworkRequests) { + observable.silentSetOptions({ fetchPolicy: "standby" }); + } else { observable.resetLastResults(); observable.silentSetOptions({ fetchPolicy: "cache-first" }); - } else { - observable.silentSetOptions({ fetchPolicy: "standby" }); } this.subscribeToQuery(); - if (originalFetchPolicy === "no-cache") { + if (avoidNetworkRequests) { return; } From 8bc7d4d406402962bf5151cdd2c5c75c9398d10c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:54:07 -0400 Subject: [PATCH 2/3] Version Packages (#11773) Co-authored-by: github-actions[bot] --- .changeset/thick-buttons-juggle.md | 5 ----- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 .changeset/thick-buttons-juggle.md diff --git a/.changeset/thick-buttons-juggle.md b/.changeset/thick-buttons-juggle.md deleted file mode 100644 index 6208d80fdb6..00000000000 --- a/.changeset/thick-buttons-juggle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix an issue where using `skipToken` or the `skip` option with `useSuspenseQuery` in React's strict mode would perform a network request. diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb64da87b8..66cd000df03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @apollo/client +## 3.9.11 + +### Patch Changes + +- [#11769](https://github.com/apollographql/apollo-client/pull/11769) [`04132af`](https://github.com/apollographql/apollo-client/commit/04132af121c9b48d6e03eb733b9b91f825defbac) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where using `skipToken` or the `skip` option with `useSuspenseQuery` in React's strict mode would perform a network request. + ## 3.9.10 ### Patch Changes diff --git a/package-lock.json b/package-lock.json index ee16767dc89..71841a502a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apollo/client", - "version": "3.9.10", + "version": "3.9.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apollo/client", - "version": "3.9.10", + "version": "3.9.11", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 988dd7102b2..f43da69fd82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apollo/client", - "version": "3.9.10", + "version": "3.9.11", "description": "A fully-featured caching GraphQL client.", "private": true, "keywords": [ From f046aa9fc24ac197a797045d280811a3bbe05806 Mon Sep 17 00:00:00 2001 From: Alessia Bellisario Date: Wed, 10 Apr 2024 09:58:00 -0400 Subject: [PATCH 3/3] chore: rename `createProxiedSchema` to `createTestSchema` (#11764) * feat: rename createProxiedSchema to createSchemaProxy * chore: add changeset * chore rename createSchemaProxy to createTestSchema and createMockFetch to createSchemaFetch --- .api-reports/api-report-testing.md | 14 +++++------ .api-reports/api-report-testing_core.md | 4 ++-- .changeset/green-garlics-protect.md | 5 ++++ config/jest.config.js | 2 +- src/__tests__/__snapshots__/exports.ts.snap | 8 +++---- ...ema.test.tsx => createTestSchema.test.tsx} | 24 +++++++++---------- ...reateMockFetch.ts => createSchemaFetch.ts} | 8 +++---- ...teProxiedSchema.ts => createTestSchema.ts} | 8 +++---- src/testing/core/index.ts | 4 ++-- 9 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 .changeset/green-garlics-protect.md rename src/testing/core/__tests__/{createProxiedSchema.test.tsx => createTestSchema.test.tsx} (97%) rename src/testing/core/{createMockFetch.ts => createSchemaFetch.ts} (92%) rename src/testing/core/{createProxiedSchema.ts => createTestSchema.ts} (94%) diff --git a/.api-reports/api-report-testing.md b/.api-reports/api-report-testing.md index 774a8e69cd1..e2734983594 100644 --- a/.api-reports/api-report-testing.md +++ b/.api-reports/api-report-testing.md @@ -450,22 +450,22 @@ type ConcastSourcesIterable = Iterable>; export function createMockClient(data: TData, query: DocumentNode, variables?: {}): ApolloClient; // @alpha -export const createMockFetch: (schema: GraphQLSchema, mockFetchOpts?: { +export const createMockSchema: (staticSchema: GraphQLSchema, mocks: { + [key: string]: any; +}) => GraphQLSchema; + +// @alpha +export const createSchemaFetch: (schema: GraphQLSchema, mockFetchOpts?: { validate: boolean; }) => { mock: (uri: any, options: any) => Promise; restore: () => void; } & Disposable; -// @alpha -export const createMockSchema: (staticSchema: GraphQLSchema, mocks: { - [key: string]: any; -}) => GraphQLSchema; - // Warning: (ae-forgotten-export) The symbol "ProxiedSchema" needs to be exported by the entry point index.d.ts // // @alpha -export const createProxiedSchema: (schemaWithMocks: GraphQLSchema, resolvers: Resolvers) => ProxiedSchema; +export const createTestSchema: (schemaWithMocks: GraphQLSchema, resolvers: Resolvers) => ProxiedSchema; // @public (undocumented) namespace DataProxy { diff --git a/.api-reports/api-report-testing_core.md b/.api-reports/api-report-testing_core.md index 42df7b5c695..0534bddcecb 100644 --- a/.api-reports/api-report-testing_core.md +++ b/.api-reports/api-report-testing_core.md @@ -449,7 +449,7 @@ type ConcastSourcesIterable = Iterable>; export function createMockClient(data: TData, query: DocumentNode, variables?: {}): ApolloClient; // @alpha -export const createMockFetch: (schema: GraphQLSchema, mockFetchOpts?: { +export const createSchemaFetch: (schema: GraphQLSchema, mockFetchOpts?: { validate: boolean; }) => { mock: (uri: any, options: any) => Promise; @@ -459,7 +459,7 @@ export const createMockFetch: (schema: GraphQLSchema, mockFetchOpts?: { // Warning: (ae-forgotten-export) The symbol "ProxiedSchema" needs to be exported by the entry point index.d.ts // // @alpha -export const createProxiedSchema: (schemaWithMocks: GraphQLSchema, resolvers: Resolvers) => ProxiedSchema; +export const createTestSchema: (schemaWithMocks: GraphQLSchema, resolvers: Resolvers) => ProxiedSchema; // @public (undocumented) namespace DataProxy { diff --git a/.changeset/green-garlics-protect.md b/.changeset/green-garlics-protect.md new file mode 100644 index 00000000000..53dbebb4f55 --- /dev/null +++ b/.changeset/green-garlics-protect.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": minor +--- + +Rename `createProxiedSchema` to `createTestSchema` and `createMockFetch` to `createSchemaFetch`. diff --git a/config/jest.config.js b/config/jest.config.js index 0375a1a071a..4832d1355c7 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -33,7 +33,7 @@ const react17TestFileIgnoreList = [ ignoreTSFiles, // We only support Suspense with React 18, so don't test suspense hooks with // React 17 - "src/testing/core/__tests__/createProxiedSchema.test.tsx", + "src/testing/core/__tests__/createTestSchema.test.tsx", "src/react/hooks/__tests__/useSuspenseQuery.test.tsx", "src/react/hooks/__tests__/useBackgroundQuery.test.tsx", "src/react/hooks/__tests__/useLoadableQuery.test.tsx", diff --git a/src/__tests__/__snapshots__/exports.ts.snap b/src/__tests__/__snapshots__/exports.ts.snap index 5744dc7b332..bee4f75643a 100644 --- a/src/__tests__/__snapshots__/exports.ts.snap +++ b/src/__tests__/__snapshots__/exports.ts.snap @@ -369,9 +369,9 @@ Array [ "MockSubscriptionLink", "MockedProvider", "createMockClient", - "createMockFetch", "createMockSchema", - "createProxiedSchema", + "createSchemaFetch", + "createTestSchema", "itAsync", "mockObservableLink", "mockSingleLink", @@ -389,8 +389,8 @@ Array [ "MockLink", "MockSubscriptionLink", "createMockClient", - "createMockFetch", - "createProxiedSchema", + "createSchemaFetch", + "createTestSchema", "itAsync", "mockObservableLink", "mockSingleLink", diff --git a/src/testing/core/__tests__/createProxiedSchema.test.tsx b/src/testing/core/__tests__/createTestSchema.test.tsx similarity index 97% rename from src/testing/core/__tests__/createProxiedSchema.test.tsx rename to src/testing/core/__tests__/createTestSchema.test.tsx index dc5f686f8c7..25dbe78631e 100644 --- a/src/testing/core/__tests__/createProxiedSchema.test.tsx +++ b/src/testing/core/__tests__/createTestSchema.test.tsx @@ -13,14 +13,14 @@ import { spyOnConsole, useTrackRenders, } from "../../internal/index.js"; -import { createProxiedSchema } from "../createProxiedSchema.js"; +import { createTestSchema } from "../createTestSchema.js"; import { GraphQLError, buildSchema } from "graphql"; import type { UseSuspenseQueryResult } from "../../../react/index.js"; import { useMutation, useSuspenseQuery } from "../../../react/index.js"; import { createMockSchema } from "../../graphql-tools/utils.js"; import userEvent from "@testing-library/user-event"; import { act, screen } from "@testing-library/react"; -import { createMockFetch } from "../createMockFetch.js"; +import { createSchemaFetch } from "../createSchemaFetch.js"; import { FallbackProps, ErrorBoundary as ReactErrorBoundary, @@ -147,7 +147,7 @@ describe("schema proxy", () => { Date: () => new Date("January 1, 2024 01:00:00").toJSON().split("T")[0], }); - const schema = createProxiedSchema(schemaWithMocks, { + const schema = createTestSchema(schemaWithMocks, { Query: { viewer: () => ({ name: "Jane Doe", @@ -173,7 +173,7 @@ describe("schema proxy", () => { it("mocks scalars and resolvers", async () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(schema); + using _fetch = createSchemaFetch(schema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -266,7 +266,7 @@ describe("schema proxy", () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -349,7 +349,7 @@ describe("schema proxy", () => { it("does not pollute the original schema", async () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(schema); + using _fetch = createSchemaFetch(schema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -444,7 +444,7 @@ describe("schema proxy", () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -566,7 +566,7 @@ describe("schema proxy", () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -709,7 +709,7 @@ describe("schema proxy", () => { const { ErrorBoundary } = createTrackedErrorComponents(Profiler); - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -789,7 +789,7 @@ describe("schema proxy", () => { const { ErrorBoundary } = createTrackedErrorComponents(Profiler); // @ts-expect-error - we're intentionally passing an invalid schema - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), @@ -849,7 +849,7 @@ describe("schema proxy", () => { it("preserves resolvers from previous calls to .add on subsequent calls to .fork", async () => { let name = "Virginia"; - const schema = createProxiedSchema(schemaWithMocks, { + const schema = createTestSchema(schemaWithMocks, { Query: { viewer: () => ({ name, @@ -908,7 +908,7 @@ describe("schema proxy", () => { const Profiler = createDefaultProfiler(); - using _fetch = createMockFetch(forkedSchema); + using _fetch = createSchemaFetch(forkedSchema); const client = new ApolloClient({ cache: new InMemoryCache(), diff --git a/src/testing/core/createMockFetch.ts b/src/testing/core/createSchemaFetch.ts similarity index 92% rename from src/testing/core/createMockFetch.ts rename to src/testing/core/createSchemaFetch.ts index 7adb50d10ae..8b9b5d82dd7 100644 --- a/src/testing/core/createMockFetch.ts +++ b/src/testing/core/createSchemaFetch.ts @@ -22,15 +22,15 @@ import { withCleanup } from "../internal/index.js"; * * @example * ```js - * using _fetch = createMockFetch(schema); // automatically restores fetch after exiting the block + * using _fetch = createSchemaFetch(schema); // automatically restores fetch after exiting the block * - * const { restore } = createMockFetch(schema); + * const { restore } = createSchemaFetch(schema); * restore(); // manually restore fetch if `using` is not supported * ``` * @since 3.10.0 * @alpha */ -const createMockFetch = ( +const createSchemaFetch = ( schema: GraphQLSchema, mockFetchOpts: { validate: boolean } = { validate: true } ) => { @@ -84,4 +84,4 @@ const createMockFetch = ( return withCleanup({ mock: mockFetch, restore }, restore); }; -export { createMockFetch }; +export { createSchemaFetch }; diff --git a/src/testing/core/createProxiedSchema.ts b/src/testing/core/createTestSchema.ts similarity index 94% rename from src/testing/core/createProxiedSchema.ts rename to src/testing/core/createTestSchema.ts index e3ceaec2043..af7911d50da 100644 --- a/src/testing/core/createProxiedSchema.ts +++ b/src/testing/core/createTestSchema.ts @@ -32,7 +32,7 @@ interface ProxiedSchemaFns { Date: () => new Date("December 10, 1815 01:00:00").toJSON().split("T")[0], }); * - * const schema = createProxiedSchema(schemaWithMocks, { + * const schema = createTestSchema(schemaWithMocks, { Query: { writer: () => ({ name: "Ada Lovelace", @@ -43,7 +43,7 @@ interface ProxiedSchemaFns { * @since 3.9.0 * @alpha */ -const createProxiedSchema = ( +const createTestSchema = ( schemaWithMocks: GraphQLSchema, resolvers: Resolvers ): ProxiedSchema => { @@ -65,7 +65,7 @@ const createProxiedSchema = ( }, fork: ({ resolvers: newResolvers } = {}) => { - return createProxiedSchema(targetSchema, newResolvers ?? targetResolvers); + return createTestSchema(targetSchema, newResolvers ?? targetResolvers); }, reset: () => { @@ -116,4 +116,4 @@ const createProxiedSchema = ( return schema as ProxiedSchema; }; -export { createProxiedSchema }; +export { createTestSchema }; diff --git a/src/testing/core/index.ts b/src/testing/core/index.ts index b9b3065b211..3aaad32032b 100644 --- a/src/testing/core/index.ts +++ b/src/testing/core/index.ts @@ -12,6 +12,6 @@ export { createMockClient } from "./mocking/mockClient.js"; export { default as subscribeAndCount } from "./subscribeAndCount.js"; export { itAsync } from "./itAsync.js"; export { wait, tick } from "./wait.js"; -export { createProxiedSchema } from "./createProxiedSchema.js"; -export { createMockFetch } from "./createMockFetch.js"; +export { createTestSchema } from "./createTestSchema.js"; +export { createSchemaFetch } from "./createSchemaFetch.js"; export * from "./withConsoleSpy.js";