Skip to content

Commit

Permalink
chore: move new testing utilities to new @apollo/client/testing/alpha…
Browse files Browse the repository at this point in the history
… entrypoint
  • Loading branch information
alessbell committed Apr 12, 2024
1 parent cde7e24 commit ad5693c
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 102 deletions.
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
85 changes: 85 additions & 0 deletions .api-reports/api-report-testing_alpha.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/alpha/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)

```
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
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", "alpha"] },
{ 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 @@ -383,13 +381,18 @@ Array [
]
`;

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

exports[`exports of public entry points @apollo/client/testing/core 1`] = `
Array [
"MockLink",
"MockSubscriptionLink",
"createMockClient",
"createSchemaFetch",
"createTestSchema",
"itAsync",
"mockObservableLink",
"mockSingleLink",
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 testingAlpha from "../testing/alpha";
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/alpha", testingAlpha);
check("@apollo/client/utilities", utilities);
check("@apollo/client/utilities/globals", utilitiesGlobals);
check("@apollo/client/utilities/subscriptions/urql", urqlUtilities);
Expand Down
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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/alpha/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";
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";

0 comments on commit ad5693c

Please sign in to comment.