Skip to content
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
15 changes: 0 additions & 15 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ import { DocumentTransformCacheKey } from '@apollo/client/utilities';
import { empty } from '@apollo/client/link';
import { enableExperimentalFragmentVariables } from 'graphql-tag';
import { execute } from '@apollo/client/link';
import { ExecutionPatchIncrementalResult } from '@apollo/client/link';
import { ExecutionPatchInitialResult } from '@apollo/client/link';
import { ExecutionPatchResult } from '@apollo/client/link';
import { fallbackHttpConfig } from '@apollo/client/link/http';
import { FetchResult } from '@apollo/client/link';
import { FieldFunctionOptions } from '@apollo/client/cache';
Expand All @@ -53,7 +50,6 @@ import { HttpLink } from '@apollo/client/link/http';
import { IdGetter } from '@apollo/client/cache';
import { IdGetterObj } from '@apollo/client/cache';
import type { Incremental } from '@apollo/client/incremental';
import { IncrementalPayload } from '@apollo/client/link';
import { InMemoryCache } from '@apollo/client/cache';
import { InMemoryCacheConfig } from '@apollo/client/cache';
import type { InteropObservable } from 'rxjs';
Expand Down Expand Up @@ -83,7 +79,6 @@ import { OperationContext } from '@apollo/client/link';
import { OperationTypeNode } from 'graphql';
import { OptimisticStoreItem } from '@apollo/client/cache';
import { parseAndCheckHttpResponse } from '@apollo/client/link/http';
import { Path } from '@apollo/client/link';
import { PossibleTypesMap } from '@apollo/client/cache';
import { ReactiveVar } from '@apollo/client/cache';
import { ReadMergeModifyContext } from '@apollo/client/cache';
Expand Down Expand Up @@ -304,12 +299,6 @@ export type ErrorPolicy = "none" | "ignore" | "all";

export { execute }

export { ExecutionPatchIncrementalResult }

export { ExecutionPatchInitialResult }

export { ExecutionPatchResult }

export { fallbackHttpConfig }

// @public (undocumented)
Expand Down Expand Up @@ -370,8 +359,6 @@ interface IgnoreModifier {
// @public (undocumented)
const _ignoreModifier: unique symbol;

export { IncrementalPayload }

export { InMemoryCache }

export { InMemoryCacheConfig }
Expand Down Expand Up @@ -672,8 +659,6 @@ namespace OverridableTypes {

export { parseAndCheckHttpResponse }

export { Path }

export { PossibleTypesMap }

// @public (undocumented)
Expand Down
36 changes: 16 additions & 20 deletions .api-reports/api-report-incremental.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,34 @@ import type { GraphQLRequest } from '@apollo/client';
// @public (undocumented)
namespace Defer20220824Handler {
// (undocumented)
type Chunk<TData = Record<string, unknown>> = InitialResult<TData> | SubsequentResult<TData>;
type Chunk<TData extends Record<string, unknown>> = InitialResult<TData> | SubsequentResult<TData>;
// (undocumented)
interface IncrementalDeferPayload<TData = Record<string, unknown>> {
// (undocumented)
data?: TData | null;
// (undocumented)
type IncrementalDeferPayload<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: Record<string, unknown>;
// (undocumented)
label?: string;
// (undocumented)
path?: Incremental.Path;
}
// (undocumented)
type IncrementalPayload<TData = Record<string, unknown>> = IncrementalDeferPayload<TData>;
label?: string;
};
// (undocumented)
type InitialResult<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, any>;
extensions?: Record<string, unknown>;
hasNext: boolean;
};
// (undocumented)
type SubsequentResult<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, unknown>;
hasNext: boolean;
incremental?: Array<IncrementalPayload<TData>>;
incremental?: Array<IncrementalDeferPayload<TData>>;
};
}

// @public (undocumented)
class Defer20220824Handler implements Incremental.Handler<Defer20220824Handler.Chunk> {
// @public
class Defer20220824Handler implements Incremental.Handler<Defer20220824Handler.Chunk<any>> {
// (undocumented)
extractErrors(result: FetchResult<any>): GraphQLFormattedError[] | undefined;
// (undocumented)
Expand All @@ -55,17 +51,17 @@ class Defer20220824Handler implements Incremental.Handler<Defer20220824Handler.C
// Warning: (ae-forgotten-export) The symbol "DeferRequest" needs to be exported by the entry point index.d.ts
//
// (undocumented)
startRequest<TData>(_: {
startRequest<TData extends Record<string, unknown>>(_: {
query: DocumentNode;
}): DeferRequest<TData>;
}
export { Defer20220824Handler }
export { Defer20220824Handler as GraphQL17Alpha2Handler }

// @public (undocumented)
class DeferRequest<TData> implements Incremental.IncrementalRequest<Defer20220824Handler.Chunk, TData> {
class DeferRequest<TData extends Record<string, unknown>> implements Incremental.IncrementalRequest<Defer20220824Handler.Chunk<TData>, TData> {
// (undocumented)
handle(cacheData: TData | DeepPartial<TData> | null | undefined, chunk: Defer20220824Handler.InitialResult | Defer20220824Handler.SubsequentResult): FormattedExecutionResult<TData>;
handle(cacheData: TData | DeepPartial<TData> | null | undefined, chunk: Defer20220824Handler.Chunk<TData>): FormattedExecutionResult<TData>;
// (undocumented)
hasNext: boolean;
}
Expand All @@ -81,7 +77,7 @@ export namespace Incremental {
// (undocumented)
prepareRequest: (request: GraphQLRequest) => GraphQLRequest;
// (undocumented)
startRequest: <TData>(request: {
startRequest: <TData extends Record<string, unknown>>(request: {
query: DocumentNode;
}) => IncrementalRequest<Chunk, TData>;
}
Expand Down
54 changes: 1 addition & 53 deletions .api-reports/api-report-link.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions =
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
payload: FormattedExecutionResult<TData, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
payload: FormattedExecutionResult<TData, TExtensions> | null;
}

// @public (undocumented)
Expand All @@ -67,41 +67,6 @@ export interface ExecuteContext {
client: ApolloClient;
}

// Warning: (ae-forgotten-export) The symbol "ExecutionPatchResultBase" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export interface ExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
// (undocumented)
data?: never;
// (undocumented)
errors?: never;
// (undocumented)
extensions?: never;
// (undocumented)
incremental?: IncrementalPayload<TData, TExtensions>[];
}

// @public (undocumented)
export interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
// (undocumented)
data: TData | null | undefined;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
incremental?: never;
}

// @public (undocumented)
export type ExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = ExecutionPatchInitialResult<TData, TExtensions> | ExecutionPatchIncrementalResult<TData, TExtensions>;

// @public (undocumented)
interface ExecutionPatchResultBase {
// (undocumented)
hasNext?: boolean;
}

// @public (undocumented)
export type FetchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = FormattedExecutionResult<TData, TExtensions> | AdditionalFetchResultTypes<TData, TExtensions>[keyof AdditionalFetchResultTypes<TData, TExtensions>];

Expand All @@ -122,20 +87,6 @@ export interface GraphQLRequest<TVariables = Record<string, any>> {
variables?: TVariables;
}

// @public (undocumented)
export interface IncrementalPayload<TData, TExtensions> {
// (undocumented)
data: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
label?: string;
// (undocumented)
path: Path;
}

// @public (undocumented)
export type NextLink = (operation: Operation) => Observable<FetchResult>;

Expand Down Expand Up @@ -164,9 +115,6 @@ export interface Operation {
export interface OperationContext extends DefaultContext {
}

// @public (undocumented)
export type Path = ReadonlyArray<string | number>;

// @public (undocumented)
export type RequestHandler = (operation: Operation, forward: NextLink) => Observable<FetchResult> | null;

Expand Down
56 changes: 2 additions & 54 deletions .api-reports/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions =
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
payload: FormattedExecutionResult<TData, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
payload: FormattedExecutionResult<TData, TExtensions> | null;
}

// @public (undocumented)
Expand Down Expand Up @@ -818,41 +818,6 @@ interface ExecuteContext {
client: ApolloClient;
}

// Warning: (ae-forgotten-export) The symbol "ExecutionPatchResultBase" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export interface ExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
// (undocumented)
data?: never;
// (undocumented)
errors?: never;
// (undocumented)
extensions?: never;
// (undocumented)
incremental?: IncrementalPayload<TData, TExtensions>[];
}

// @public (undocumented)
export interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
// (undocumented)
data: TData | null | undefined;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
incremental?: never;
}

// @public (undocumented)
export type ExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = ExecutionPatchInitialResult<TData, TExtensions> | ExecutionPatchIncrementalResult<TData, TExtensions>;

// @public (undocumented)
interface ExecutionPatchResultBase {
// (undocumented)
hasNext?: boolean;
}

// @public
type ExtractByMatchingTypeNames<Union extends {
__typename?: string;
Expand Down Expand Up @@ -1284,7 +1249,7 @@ namespace Incremental {
// Warning: (ae-forgotten-export) The symbol "Incremental" needs to be exported by the entry point index.d.ts
//
// (undocumented)
startRequest: <TData>(request: {
startRequest: <TData extends Record<string, unknown>>(request: {
query: DocumentNode;
}) => IncrementalRequest<Chunk, TData>;
}
Expand All @@ -1299,20 +1264,6 @@ namespace Incremental {
type Path = ReadonlyArray<string | number>;
}

// @public (undocumented)
export interface IncrementalPayload<TData, TExtensions> {
// (undocumented)
data: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
label?: string;
// (undocumented)
path: Path;
}

// @public (undocumented)
type InferContextValueFromResolvers<TResolvers> = TResolvers extends {
[typename: string]: infer TFieldResolvers;
Expand Down Expand Up @@ -2054,9 +2005,6 @@ namespace OverridableTypes {
// @public (undocumented)
export function parseAndCheckHttpResponse(operations: Operation | Operation[]): (response: Response) => Promise<any>;

// @public (undocumented)
export type Path = ReadonlyArray<string | number>;

// @public (undocumented)
class Policies {
constructor(config: {
Expand Down
11 changes: 11 additions & 0 deletions .changeset/fuzzy-plants-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@apollo/client": patch
---

Remove these incremental-format-specific types:

* `ExecutionPatchIncrementalResult`
* `ExecutionPatchInitialResult`
* `ExecutionPatchResult`
* `IncrementalPayload`
* `Path`
7 changes: 7 additions & 0 deletions .changeset/lazy-baboons-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@apollo/client": patch
---

Slightly rework multipart response parsing.

This removes last incremental-protocol-specific details from `HttpLink` and `BatchHttpLink`.
8 changes: 4 additions & 4 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 43678,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38629,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33368,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27606
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 43524,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38516,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33302,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27599
}
25 changes: 17 additions & 8 deletions src/core/QueryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import type { ObservableQuery } from "./ObservableQuery.js";
import type { QueryManager } from "./QueryManager.js";
import type {
DefaultContext,
NormalizedExecutionResult,
InternalRefetchQueriesInclude,
MutationQueryReducer,
MutationUpdaterFunction,
NormalizedExecutionResult,
OnQueryUpdated,
OperationVariables,
Streaming,
Expand Down Expand Up @@ -182,9 +183,14 @@ export class QueryInfo<
const { incrementalHandler } = this.queryManager;

if (incrementalHandler.isIncrementalResult(incoming)) {
this.incremental ||= incrementalHandler.startRequest({
this.incremental ||= incrementalHandler.startRequest<
TData & Record<string, unknown>
>({
query,
});
}) as Incremental.IncrementalRequest<
Record<string, unknown>,
TData | Streaming<TData>
>;

return this.incremental.handle(cacheData, incoming);
}
Expand Down Expand Up @@ -402,11 +408,14 @@ export class QueryInfo<

if (complete && currentQueryResult) {
// Run our reducer using the current query result and the mutation result.
const nextQueryResult = updater(currentQueryResult, {
mutationResult: getResultWithDataState(),
queryName: (document && getOperationName(document)) || void 0,
queryVariables: variables!,
});
const nextQueryResult = (updater as MutationQueryReducer<any>)(
currentQueryResult,
{
mutationResult: getResultWithDataState(),
queryName: (document && getOperationName(document)) || void 0,
queryVariables: variables!,
}
);

// Write the modified result back into the store if we got a new result.
if (nextQueryResult) {
Expand Down
Loading