Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move new testing utilities to their own entrypoint #11783

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions .api-reports/api-report-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

```ts

/// <reference types="node" />

import type { ASTNode } from 'graphql';
import type { DocumentNode } from 'graphql';
import type { ExecutionResult } from 'graphql';
import type { FieldNode } from 'graphql';
import type { FragmentDefinitionNode } from 'graphql';
import type { GraphQLError } from 'graphql';
import type { GraphQLErrorExtensions } from 'graphql';
import type { GraphQLSchema } from 'graphql';
import { Observable } from 'zen-observable-ts';
import type { Observer } from 'zen-observable-ts';
import * as React_2 from 'react';
Expand Down Expand Up @@ -449,21 +446,6 @@ type ConcastSourcesIterable<T> = Iterable<Source<T>>;
// @public (undocumented)
export function createMockClient<TData>(data: TData, query: DocumentNode, variables?: {}): ApolloClient<NormalizedCacheObject>;

// @alpha
export const createSchemaFetch: (schema: GraphQLSchema, mockFetchOpts?: {
validate: boolean;
}) => ((uri: any, options: any) => Promise<Response>) & {
mockGlobal: () => {
restore: () => void;
} & Disposable;
};

// Warning: (ae-forgotten-export) The symbol "TestSchemaOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ProxiedSchema" needs to be exported by the entry point index.d.ts
//
// @alpha
export const createTestSchema: (schemaWithTypeDefs: GraphQLSchema, options: TestSchemaOptions) => ProxiedSchema;

// @public (undocumented)
namespace DataProxy {
// (undocumented)
Expand Down Expand Up @@ -1283,11 +1265,6 @@ type Path = ReadonlyArray<string | number>;
// @public (undocumented)
type Primitive = null | undefined | string | number | boolean | symbol | bigint;

// Warning: (ae-forgotten-export) The symbol "TestSchemaFns" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type ProxiedSchema = GraphQLSchema & TestSchemaFns;

// @public (undocumented)
class QueryInfo {
constructor(queryManager: QueryManager<any>, queryId?: string);
Expand Down Expand Up @@ -1664,30 +1641,6 @@ interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {
variables?: TVariables;
}

// @public (undocumented)
interface TestSchemaFns {
// (undocumented)
add: (addOptions: {
resolvers: Resolvers;
}) => ProxiedSchema;
// (undocumented)
fork: (forkOptions?: {
resolvers?: Resolvers;
}) => ProxiedSchema;
// (undocumented)
reset: () => void;
}

// @public (undocumented)
interface TestSchemaOptions {
// (undocumented)
resolvers: Resolvers;
// (undocumented)
scalars?: {
[key: string]: any;
};
}

// @public (undocumented)
export function tick(): Promise<void>;

Expand Down
47 changes: 0 additions & 47 deletions .api-reports/api-report-testing_core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

```ts

/// <reference types="node" />

import type { ASTNode } from 'graphql';
import type { DocumentNode } from 'graphql';
import type { ExecutionResult } from 'graphql';
import type { FieldNode } from 'graphql';
import type { FragmentDefinitionNode } from 'graphql';
import type { GraphQLError } from 'graphql';
import type { GraphQLErrorExtensions } from 'graphql';
import type { GraphQLSchema } from 'graphql';
import { Observable } from 'zen-observable-ts';
import type { Observer } from 'zen-observable-ts';
import type { Subscriber } from 'zen-observable-ts';
Expand Down Expand Up @@ -448,21 +445,6 @@ type ConcastSourcesIterable<T> = Iterable<Source<T>>;
// @public (undocumented)
export function createMockClient<TData>(data: TData, query: DocumentNode, variables?: {}): ApolloClient<NormalizedCacheObject>;

// @alpha
export const createSchemaFetch: (schema: GraphQLSchema, mockFetchOpts?: {
validate: boolean;
}) => ((uri: any, options: any) => Promise<Response>) & {
mockGlobal: () => {
restore: () => void;
} & Disposable;
};

// Warning: (ae-forgotten-export) The symbol "TestSchemaOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ProxiedSchema" needs to be exported by the entry point index.d.ts
//
// @alpha
export const createTestSchema: (schemaWithTypeDefs: GraphQLSchema, options: TestSchemaOptions) => ProxiedSchema;

// @public (undocumented)
namespace DataProxy {
// (undocumented)
Expand Down Expand Up @@ -1238,11 +1220,6 @@ type Path = ReadonlyArray<string | number>;
// @public (undocumented)
type Primitive = null | undefined | string | number | boolean | symbol | bigint;

// Warning: (ae-forgotten-export) The symbol "TestSchemaFns" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type ProxiedSchema = GraphQLSchema & TestSchemaFns;

// @public (undocumented)
class QueryInfo {
constructor(queryManager: QueryManager<any>, queryId?: string);
Expand Down Expand Up @@ -1621,30 +1598,6 @@ interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {
variables?: TVariables;
}

// @public (undocumented)
interface TestSchemaFns {
// (undocumented)
add: (addOptions: {
resolvers: Resolvers;
}) => ProxiedSchema;
// (undocumented)
fork: (forkOptions?: {
resolvers?: Resolvers;
}) => ProxiedSchema;
// (undocumented)
reset: () => void;
}

// @public (undocumented)
interface TestSchemaOptions {
// (undocumented)
resolvers: Resolvers;
// (undocumented)
scalars?: {
[key: string]: any;
};
}

// @public (undocumented)
export function tick(): Promise<void>;

Expand Down
85 changes: 85 additions & 0 deletions .api-reports/api-report-testing_experimental.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## API Report File for "@apollo/client"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

/// <reference types="node" />

import type { FieldNode } from 'graphql';
import type { FragmentDefinitionNode } from 'graphql';
import type { GraphQLSchema } from 'graphql';

// @alpha
export const createSchemaFetch: (schema: GraphQLSchema, mockFetchOpts?: {
validate: boolean;
}) => ((uri: any, options: any) => Promise<Response>) & {
mockGlobal: () => {
restore: () => void;
} & Disposable;
};

// Warning: (ae-forgotten-export) The symbol "TestSchemaOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ProxiedSchema" needs to be exported by the entry point index.d.ts
//
// @alpha
export const createTestSchema: (schemaWithTypeDefs: GraphQLSchema, options: TestSchemaOptions) => ProxiedSchema;

// @public
interface FragmentMap {
// (undocumented)
[fragmentName: string]: FragmentDefinitionNode;
}

// Warning: (ae-forgotten-export) The symbol "TestSchemaFns" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type ProxiedSchema = GraphQLSchema & TestSchemaFns;

// @public (undocumented)
type Resolver = (rootValue?: any, args?: any, context?: any, info?: {
field: FieldNode;
fragmentMap: FragmentMap;
}) => any;

// @public (undocumented)
interface Resolvers {
// (undocumented)
[key: string]: {
[field: string]: Resolver;
};
}

// @public (undocumented)
interface TestSchemaFns {
// (undocumented)
add: (addOptions: {
resolvers: Resolvers;
}) => ProxiedSchema;
// (undocumented)
fork: (forkOptions?: {
resolvers?: Resolvers;
}) => ProxiedSchema;
// (undocumented)
reset: () => void;
}

// @public (undocumented)
interface TestSchemaOptions {
// (undocumented)
resolvers: Resolvers;
// (undocumented)
scalars?: {
[key: string]: any;
};
}

// Warnings were encountered during analysis:
//
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/types.ts:203:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/testing/experimental/createTestSchema.ts:10:23 - (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

```
5 changes: 5 additions & 0 deletions .changeset/wet-plants-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": minor
---

Moves new testing utilities to their own entrypoint, `testing/experimental`
1 change: 1 addition & 0 deletions config/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const entryPoints = [
{ dirs: ["react", "ssr"] },
{ dirs: ["testing"], extensions: [".js", ".jsx"] },
{ dirs: ["testing", "core"] },
{ dirs: ["testing", "experimental"] },
{ dirs: ["utilities"] },
{ dirs: ["utilities", "subscriptions", "relay"] },
{ dirs: ["utilities", "subscriptions", "urql"] },
Expand Down
11 changes: 7 additions & 4 deletions src/__tests__/__snapshots__/exports.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ Array [
"MockSubscriptionLink",
"MockedProvider",
"createMockClient",
"createSchemaFetch",
"createTestSchema",
"itAsync",
"mockObservableLink",
"mockSingleLink",
Expand All @@ -388,8 +386,6 @@ Array [
"MockLink",
"MockSubscriptionLink",
"createMockClient",
"createSchemaFetch",
"createTestSchema",
"itAsync",
"mockObservableLink",
"mockSingleLink",
Expand All @@ -402,6 +398,13 @@ Array [
]
`;

exports[`exports of public entry points @apollo/client/testing/experimental 1`] = `
Array [
"createSchemaFetch",
"createTestSchema",
]
`;

exports[`exports of public entry points @apollo/client/utilities 1`] = `
Array [
"AutoCleanedStrongCache",
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import * as reactParser from "../react/parser";
import * as reactSSR from "../react/ssr";
import * as testing from "../testing";
import * as testingCore from "../testing/core";
import * as testingExperimental from "../testing/experimental";
import * as utilities from "../utilities";
import * as utilitiesGlobals from "../utilities/globals";
import * as urqlUtilities from "../utilities/subscriptions/urql";
Expand Down Expand Up @@ -77,6 +78,7 @@ describe("exports of public entry points", () => {
check("@apollo/client/react/ssr", reactSSR);
check("@apollo/client/testing", testing);
check("@apollo/client/testing/core", testingCore);
check("@apollo/client/testing/experimental", testingExperimental);
check("@apollo/client/utilities", utilities);
check("@apollo/client/utilities/globals", utilitiesGlobals);
check("@apollo/client/utilities/subscriptions/urql", urqlUtilities);
Expand Down
2 changes: 0 additions & 2 deletions src/testing/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ 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 { createTestSchema } from "./createTestSchema.js";
export { createSchemaFetch } from "./createSchemaFetch.js";
export * from "./withConsoleSpy.js";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { addResolversToSchema } from "@graphql-tools/schema";
import type { GraphQLSchema } from "graphql";

import { createMockSchema } from "../graphql-tools/utils.js";
import { createMockSchema } from "./graphql-tools/utils.js";
import type { Resolvers } from "../../core/types.js";

type ProxiedSchema = GraphQLSchema & TestSchemaFns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
isUnionType,
} from "graphql";

import { isNonNullObject } from "../../utilities/index.js";
import { isNonNullObject } from "../../../utilities/index.js";
import { MapperKind, mapSchema, getRootTypeNames } from "@graphql-tools/utils";

// Taken from @graphql-tools/mock:
Expand Down
2 changes: 2 additions & 0 deletions src/testing/experimental/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { createTestSchema } from "./createTestSchema.js";
export { createSchemaFetch } from "./createSchemaFetch.js";
Loading