From 579330147d6bd6f7167a35413a33746103e375cb Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Tue, 9 Jul 2024 17:43:13 +0200 Subject: [PATCH] Change usages of the `GraphQLError` type to `GraphQLFormattedError`. (#11789) * post-process errors received from responses into GraphQLError instances * adjust types, add test * fixing more types * Clean up Prettier, Size-limit, and Api-Extractor * remove runtime components * add eslint rule * Clean up Prettier, Size-limit, and Api-Extractor * adjust some more * adjustments * change patch level --------- Co-authored-by: phryneas --- .api-reports/api-report-core.api.md | 35 +++++++++--------- .api-reports/api-report-errors.api.md | 24 +++++++----- .../api-report-link_batch-http.api.md | 13 ++++--- .api-reports/api-report-link_batch.api.md | 13 ++++--- .api-reports/api-report-link_context.api.md | 13 ++++--- .api-reports/api-report-link_core.api.md | 13 ++++--- .api-reports/api-report-link_error.api.md | 23 ++++++------ .api-reports/api-report-link_http.api.md | 13 ++++--- .../api-report-link_persisted-queries.api.md | 18 +++++---- .../api-report-link_remove-typename.api.md | 13 ++++--- .api-reports/api-report-link_retry.api.md | 13 ++++--- .api-reports/api-report-link_schema.api.md | 13 ++++--- .../api-report-link_subscriptions.api.md | 13 ++++--- .api-reports/api-report-link_ws.api.md | 13 ++++--- .api-reports/api-report-react.api.md | 35 +++++++++--------- .../api-report-react_components.api.md | 35 +++++++++--------- .api-reports/api-report-react_context.api.md | 35 +++++++++--------- .api-reports/api-report-react_hoc.api.md | 35 +++++++++--------- .api-reports/api-report-react_hooks.api.md | 35 +++++++++--------- .api-reports/api-report-react_internal.api.md | 35 +++++++++--------- .api-reports/api-report-react_ssr.api.md | 35 +++++++++--------- .api-reports/api-report-testing.api.md | 35 +++++++++--------- .api-reports/api-report-testing_core.api.md | 35 +++++++++--------- .api-reports/api-report-utilities.api.md | 37 +++++++++---------- .api-reports/api-report.api.md | 35 +++++++++--------- .changeset/slimy-berries-yawn.md | 14 +++++++ .eslintrc | 16 ++++++++ src/__tests__/client.ts | 6 +-- src/core/ApolloClient.ts | 6 ++- src/core/QueryInfo.ts | 4 +- src/core/types.ts | 4 +- src/errors/__tests__/ApolloError.ts | 17 ++++----- src/errors/index.ts | 30 +++++++++++---- src/link/core/types.ts | 10 +++-- src/link/error/index.ts | 8 ++-- src/link/persisted-queries/index.ts | 28 +++++++++----- src/link/subscriptions/index.ts | 6 ++- .../__tests__/client/Mutation.test.tsx | 8 +++- src/testing/experimental/createSchemaFetch.ts | 13 ++++++- 39 files changed, 442 insertions(+), 345 deletions(-) create mode 100644 .changeset/slimy-berries-yawn.md diff --git a/.api-reports/api-report-core.api.md b/.api-reports/api-report-core.api.md index 92b34976cf..815cb7391a 100644 --- a/.api-reports/api-report-core.api.md +++ b/.api-reports/api-report-core.api.md @@ -9,12 +9,12 @@ import { disableExperimentalFragmentVariables } from 'graphql-tag'; import { disableFragmentWarnings } from 'graphql-tag'; import type { DocumentNode } from 'graphql'; import { enableExperimentalFragmentVariables } from 'graphql-tag'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; import { gql } from 'graphql-tag'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import type { InlineFragmentNode } from 'graphql'; import { InvariantError } from 'ts-invariant'; import { Observable } from 'zen-observable-ts'; @@ -94,7 +94,7 @@ export class ApolloClient implements DataProxy { __actionHookForDevTools(cb: () => any): void; constructor(options: ApolloClientOptions); // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; addResolvers(resolvers: Resolvers | Resolvers[]): void; // (undocumented) cache: ApolloCache; @@ -179,17 +179,15 @@ export class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -212,7 +210,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -266,7 +264,7 @@ export interface ApolloQueryResult { // (undocumented) data: T; error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // (undocumented) @@ -776,7 +774,7 @@ export interface ExecutionPatchInitialResult, TExten // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -993,9 +991,6 @@ const getInMemoryCacheMemoryInternals: (() => { export { gql } -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) export interface GraphQLRequest> { // (undocumented) @@ -1080,7 +1075,7 @@ export interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1712,7 +1707,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -2089,11 +2084,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-errors.api.md b/.api-reports/api-report-errors.api.md index 2b3d65a055..96c8bafc99 100644 --- a/.api-reports/api-report-errors.api.md +++ b/.api-reports/api-report-errors.api.md @@ -4,23 +4,23 @@ ```ts -import type { ExecutionResult } from 'graphql'; import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; // @public (undocumented) export class ApolloError extends Error { constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -46,7 +46,7 @@ export interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -81,7 +81,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -113,7 +113,7 @@ type FetchResultWithSymbolExtensions = FetchResult & { extensions: Record; }; -// @public (undocumented) +// @public @deprecated (undocumented) export type GraphQLErrors = ReadonlyArray; // Warning: (ae-forgotten-export) The symbol "FetchResultWithSymbolExtensions" needs to be exported by the entry point index.d.ts @@ -126,7 +126,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -166,11 +166,15 @@ type ServerParseError = Error & { // Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts // // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_batch-http.api.md b/.api-reports/api-report-link_batch-http.api.md index 89008cc698..f212ce55c0 100644 --- a/.api-reports/api-report-link_batch-http.api.md +++ b/.api-reports/api-report-link_batch-http.api.md @@ -6,8 +6,7 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -117,7 +116,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -179,7 +178,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -232,11 +231,15 @@ interface Printer { type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-link_batch.api.md b/.api-reports/api-report-link_batch.api.md index 6f6464edbb..f7e4426ef6 100644 --- a/.api-reports/api-report-link_batch.api.md +++ b/.api-reports/api-report-link_batch.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -107,7 +106,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -153,7 +152,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -208,11 +207,15 @@ type Path = ReadonlyArray; type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_context.api.md b/.api-reports/api-report-link_context.api.md index 76a7c4e534..cbf51621b3 100644 --- a/.api-reports/api-report-link_context.api.md +++ b/.api-reports/api-report-link_context.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -80,7 +79,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -124,7 +123,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -169,11 +168,15 @@ type RequestHandler = (operation: Operation, forward: NextLink) => Observable, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_core.api.md b/.api-reports/api-report-link_core.api.md index ce472253f3..32f6e56f60 100644 --- a/.api-reports/api-report-link_core.api.md +++ b/.api-reports/api-report-link_core.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -83,7 +82,7 @@ export interface ExecutionPatchInitialResult, TExten // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -126,7 +125,7 @@ export interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -164,11 +163,15 @@ export type Path = ReadonlyArray; export type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-link_error.api.md b/.api-reports/api-report-link_error.api.md index 245cc7946c..92cbae62eb 100644 --- a/.api-reports/api-report-link_error.api.md +++ b/.api-reports/api-report-link_error.api.md @@ -5,8 +5,8 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -80,10 +80,8 @@ export class ErrorLink extends ApolloLink { export interface ErrorResponse { // (undocumented) forward: NextLink; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors?: GraphQLErrors; + graphQLErrors?: ReadonlyArray; // Warning: (ae-forgotten-export) The symbol "NetworkError" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -91,7 +89,7 @@ export interface ErrorResponse { // (undocumented) operation: Operation; // (undocumented) - response?: ExecutionResult; + response?: FormattedExecutionResult; } // Warning: (ae-forgotten-export) The symbol "ExecutionPatchResultBase" needs to be exported by the entry point index.d.ts @@ -115,7 +113,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -140,9 +138,6 @@ interface ExecutionPatchResultBase { // @public (undocumented) type FetchResult, TContext = Record, TExtensions = Record> = SingleExecutionResult | ExecutionPatchResult; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts @@ -164,7 +159,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -227,11 +222,15 @@ type ServerParseError = Error & { }; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_http.api.md b/.api-reports/api-report-link_http.api.md index 6e74d1fd37..dd7cf6778c 100644 --- a/.api-reports/api-report-link_http.api.md +++ b/.api-reports/api-report-link_http.api.md @@ -6,8 +6,7 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { InvariantError } from 'ts-invariant'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -116,7 +115,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -217,7 +216,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -311,11 +310,15 @@ export type ServerParseError = Error & { }; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-link_persisted-queries.api.md b/.api-reports/api-report-link_persisted-queries.api.md index 7a977f4ce5..0e4fa0e463 100644 --- a/.api-reports/api-report-link_persisted-queries.api.md +++ b/.api-reports/api-report-link_persisted-queries.api.md @@ -5,8 +5,8 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -88,7 +88,7 @@ type ErrorMeta = { // @public (undocumented) export interface ErrorResponse { // (undocumented) - graphQLErrors?: readonly GraphQLError[]; + graphQLErrors?: ReadonlyArray; // Warning: (ae-forgotten-export) The symbol "ErrorMeta" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -100,7 +100,7 @@ export interface ErrorResponse { // (undocumented) operation: Operation; // (undocumented) - response?: ExecutionResult; + response?: FormattedExecutionResult; } // Warning: (ae-forgotten-export) The symbol "ExecutionPatchResultBase" needs to be exported by the entry point index.d.ts @@ -124,7 +124,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -173,7 +173,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -263,11 +263,15 @@ type ServerParseError = Error & { type SHA256Function = (...args: any[]) => string | PromiseLike; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-link_remove-typename.api.md b/.api-reports/api-report-link_remove-typename.api.md index 05dcca3dac..7d088615a2 100644 --- a/.api-reports/api-report-link_remove-typename.api.md +++ b/.api-reports/api-report-link_remove-typename.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -75,7 +74,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -121,7 +120,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -191,11 +190,15 @@ export interface RemoveTypenameFromVariablesOptions { type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_retry.api.md b/.api-reports/api-report-link_retry.api.md index 173a281dd6..843ff5f165 100644 --- a/.api-reports/api-report-link_retry.api.md +++ b/.api-reports/api-report-link_retry.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -88,7 +87,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -134,7 +133,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -208,11 +207,15 @@ export class RetryLink extends ApolloLink { } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_schema.api.md b/.api-reports/api-report-link_schema.api.md index 14459f745e..817398b759 100644 --- a/.api-reports/api-report-link_schema.api.md +++ b/.api-reports/api-report-link_schema.api.md @@ -5,8 +5,7 @@ ```ts import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import type { GraphQLSchema } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -76,7 +75,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -122,7 +121,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -194,11 +193,15 @@ export class SchemaLink extends ApolloLink { } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_subscriptions.api.md b/.api-reports/api-report-link_subscriptions.api.md index a67c541572..b7fcb443f8 100644 --- a/.api-reports/api-report-link_subscriptions.api.md +++ b/.api-reports/api-report-link_subscriptions.api.md @@ -6,8 +6,7 @@ import type { Client } from 'graphql-ws'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; @@ -76,7 +75,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -133,7 +132,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -173,11 +172,15 @@ type Path = ReadonlyArray; type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-link_ws.api.md b/.api-reports/api-report-link_ws.api.md index 7969b0cdbc..ec666d00c7 100644 --- a/.api-reports/api-report-link_ws.api.md +++ b/.api-reports/api-report-link_ws.api.md @@ -6,8 +6,7 @@ import type { ClientOptions } from 'subscriptions-transport-ws'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; -import type { GraphQLError } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import { SubscriptionClient } from 'subscriptions-transport-ws'; @@ -77,7 +76,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -123,7 +122,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -163,11 +162,15 @@ type Path = ReadonlyArray; type RequestHandler = (operation: Operation, forward: NextLink) => Observable | null; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react.api.md b/.api-reports/api-report-react.api.md index 916035b05c..32dd9f8010 100644 --- a/.api-reports/api-report-react.api.md +++ b/.api-reports/api-report-react.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type * as ReactTypes from 'react'; @@ -102,7 +102,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -230,17 +230,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -266,7 +264,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -332,7 +330,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -760,7 +758,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -874,9 +872,6 @@ const getApolloClientMemoryInternals: (() => { // @public (undocumented) export function getApolloContext(): ReactTypes.Context; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -915,7 +910,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1480,7 +1475,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1878,11 +1873,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = Context, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = Context, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_components.api.md b/.api-reports/api-report-react_components.api.md index 90af57d6d2..a1e25d6977 100644 --- a/.api-reports/api-report-react_components.api.md +++ b/.api-reports/api-report-react_components.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import * as PropTypes from 'prop-types'; @@ -102,7 +102,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -208,17 +208,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -244,7 +242,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -297,7 +295,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -692,7 +690,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -793,9 +791,6 @@ const getApolloClientMemoryInternals: (() => { }; }) | undefined; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -824,7 +819,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1300,7 +1295,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1631,11 +1626,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_context.api.md b/.api-reports/api-report-react_context.api.md index f2ec9bb082..4c0c8a8991 100644 --- a/.api-reports/api-report-react_context.api.md +++ b/.api-reports/api-report-react_context.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type * as ReactTypes from 'react'; @@ -101,7 +101,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -228,17 +228,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -264,7 +262,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -328,7 +326,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -687,7 +685,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -791,9 +789,6 @@ const getApolloClientMemoryInternals: (() => { // @public (undocumented) export function getApolloContext(): ReactTypes.Context; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -822,7 +817,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1229,7 +1224,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1585,11 +1580,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_hoc.api.md b/.api-reports/api-report-react_hoc.api.md index f82219194f..ad7a5bf8b4 100644 --- a/.api-reports/api-report-react_hoc.api.md +++ b/.api-reports/api-report-react_hoc.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type * as ReactTypes from 'react'; @@ -101,7 +101,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -207,17 +207,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -243,7 +241,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -296,7 +294,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -685,7 +683,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -798,9 +796,6 @@ const getApolloClientMemoryInternals: (() => { // @public @deprecated (undocumented) export function graphql> & Partial>>(document: DocumentNode, operationOptions?: OperationOption): (WrappedComponent: ReactTypes.ComponentType) => ReactTypes.ComponentClass; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -829,7 +824,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1274,7 +1269,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1591,11 +1586,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_hooks.api.md b/.api-reports/api-report-react_hooks.api.md index 094ea9d31a..2137e1da77 100644 --- a/.api-reports/api-report-react_hooks.api.md +++ b/.api-reports/api-report-react_hooks.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type { Subscriber } from 'zen-observable-ts'; @@ -100,7 +100,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -206,17 +206,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -242,7 +240,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -295,7 +293,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -715,7 +713,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -826,9 +824,6 @@ const getApolloClientMemoryInternals: (() => { }; }) | undefined; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -857,7 +852,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1355,7 +1350,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1714,11 +1709,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_internal.api.md b/.api-reports/api-report-react_internal.api.md index 81bffbb745..993f35c561 100644 --- a/.api-reports/api-report-react_internal.api.md +++ b/.api-reports/api-report-react_internal.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type { Subscriber } from 'zen-observable-ts'; @@ -100,7 +100,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -206,17 +206,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -242,7 +240,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -295,7 +293,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -700,7 +698,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -834,9 +832,6 @@ export function getSuspenseCache(client: ApolloClient & { // @public (undocumented) export function getWrappedPromise(queryRef: WrappedQueryRef): QueryRefPromise; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -872,7 +867,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1401,7 +1396,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1765,11 +1760,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-react_ssr.api.md b/.api-reports/api-report-react_ssr.api.md index ca7a9f6f20..6db286b108 100644 --- a/.api-reports/api-report-react_ssr.api.md +++ b/.api-reports/api-report-react_ssr.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type * as ReactTypes from 'react'; @@ -101,7 +101,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -207,17 +207,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -243,7 +241,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -296,7 +294,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -656,7 +654,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -776,9 +774,6 @@ type GetMarkupFromTreeOptions = { renderFunction?: (tree: ReactTypes.ReactElement) => string | PromiseLike; }; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -807,7 +802,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1214,7 +1209,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1570,11 +1565,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-testing.api.md b/.api-reports/api-report-testing.api.md index ffcefbd2d4..170a8acc43 100644 --- a/.api-reports/api-report-testing.api.md +++ b/.api-reports/api-report-testing.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import * as React_2 from 'react'; @@ -101,7 +101,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -207,17 +207,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -243,7 +241,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -296,7 +294,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -657,7 +655,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -758,9 +756,6 @@ const getApolloClientMemoryInternals: (() => { }; }) | undefined; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -789,7 +784,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1297,7 +1292,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1617,11 +1612,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-testing_core.api.md b/.api-reports/api-report-testing_core.api.md index b065971038..aacf32eccc 100644 --- a/.api-reports/api-report-testing_core.api.md +++ b/.api-reports/api-report-testing_core.api.md @@ -6,11 +6,11 @@ import type { ASTNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import { Observable } from 'zen-observable-ts'; import type { Observer } from 'zen-observable-ts'; import type { Subscriber } from 'zen-observable-ts'; @@ -100,7 +100,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -206,17 +206,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -242,7 +240,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -295,7 +293,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -656,7 +654,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -757,9 +755,6 @@ const getApolloClientMemoryInternals: (() => { }; }) | undefined; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -788,7 +783,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1252,7 +1247,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -1574,11 +1569,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report-utilities.api.md b/.api-reports/api-report-utilities.api.md index 7b26126fdc..8dc5e2982b 100644 --- a/.api-reports/api-report-utilities.api.md +++ b/.api-reports/api-report-utilities.api.md @@ -8,12 +8,12 @@ import type { ArgumentNode } from 'graphql'; import type { ASTNode } from 'graphql'; import type { DirectiveNode } from 'graphql'; import type { DocumentNode } from 'graphql'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; import type { FragmentSpreadNode } from 'graphql'; -import { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import { GraphQLFormattedError } from 'graphql'; import type { InlineFragmentNode } from 'graphql'; import type { NameNode } from 'graphql'; import { Observable } from 'zen-observable-ts'; @@ -114,7 +114,7 @@ class ApolloClient implements DataProxy { // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts addResolvers(resolvers: Resolvers | Resolvers[]): void; // Warning: (ae-forgotten-export) The symbol "ApolloCache" needs to be exported by the entry point index.d.ts @@ -219,17 +219,15 @@ class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -255,7 +253,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -319,7 +317,7 @@ interface ApolloQueryResult { data: T; // Warning: (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts @@ -963,7 +961,7 @@ interface ExecutionPatchInitialResult, TExtensions = // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1169,7 +1167,7 @@ export function getFragmentQueryDocument(document: DocumentNode, fragmentName?: export type GetFragmentSpreadConfig = GetNodeConfig; // @public (undocumented) -export function getGraphQLErrorsFromResult(result: FetchResult): GraphQLError[]; +export function getGraphQLErrorsFromResult(result: FetchResult): GraphQLFormattedError[]; // @public (undocumented) export function getInclusionDirectives(directives: ReadonlyArray): InclusionDirectives; @@ -1220,9 +1218,6 @@ export const getStoreKeyName: ((fieldName: string, args?: Record | // @public (undocumented) export function getTypenameFromResult(result: Record, selectionSet: SelectionSetNode, fragmentMap?: FragmentMap): string | undefined; -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) interface GraphQLRequest> { // (undocumented) @@ -1287,7 +1282,7 @@ interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -2016,7 +2011,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -2418,11 +2413,15 @@ interface SharedWatchQueryOptions export function shouldInclude({ directives }: SelectionNode, variables?: Record): boolean; // @public (undocumented) -interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.api-reports/api-report.api.md b/.api-reports/api-report.api.md index a56145500e..b8b6d18064 100644 --- a/.api-reports/api-report.api.md +++ b/.api-reports/api-report.api.md @@ -9,12 +9,12 @@ import { disableExperimentalFragmentVariables } from 'graphql-tag'; import { disableFragmentWarnings } from 'graphql-tag'; import type { DocumentNode } from 'graphql'; import { enableExperimentalFragmentVariables } from 'graphql-tag'; -import type { ExecutionResult } from 'graphql'; import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; import { gql } from 'graphql-tag'; -import type { GraphQLError } from 'graphql'; import type { GraphQLErrorExtensions } from 'graphql'; +import type { GraphQLFormattedError } from 'graphql'; import type { InlineFragmentNode } from 'graphql'; import { InvariantError } from 'ts-invariant'; import { Observable } from 'zen-observable-ts'; @@ -96,7 +96,7 @@ export class ApolloClient implements DataProxy { __actionHookForDevTools(cb: () => any): void; constructor(options: ApolloClientOptions); // (undocumented) - __requestRaw(payload: GraphQLRequest): Observable; + __requestRaw(payload: GraphQLRequest): Observable; addResolvers(resolvers: Resolvers | Resolvers[]): void; // (undocumented) cache: ApolloCache; @@ -202,17 +202,15 @@ export class ApolloError extends Error { // Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions); cause: ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) | null; + readonly message: string; + extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // (undocumented) clientErrors: ReadonlyArray; // (undocumented) extraInfo: any; - // Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts - // // (undocumented) - graphQLErrors: GraphQLErrors; + graphQLErrors: ReadonlyArray; // (undocumented) message: string; // (undocumented) @@ -235,7 +233,7 @@ interface ApolloErrorOptions { // (undocumented) extraInfo?: any; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) networkError?: Error | ServerParseError | ServerError | null; // (undocumented) @@ -302,7 +300,7 @@ export interface ApolloQueryResult { // (undocumented) data: T; error?: ApolloError; - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) loading: boolean; // (undocumented) @@ -888,7 +886,7 @@ export interface ExecutionPatchInitialResult, TExten // (undocumented) data: TData | null | undefined; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -1116,9 +1114,6 @@ const getInMemoryCacheMemoryInternals: (() => { export { gql } -// @public (undocumented) -type GraphQLErrors = ReadonlyArray; - // @public (undocumented) export interface GraphQLRequest> { // (undocumented) @@ -1213,7 +1208,7 @@ export interface IncrementalPayload { // (undocumented) data: TData | null; // (undocumented) - errors?: ReadonlyArray; + errors?: ReadonlyArray; // (undocumented) extensions?: TExtensions; // (undocumented) @@ -2056,7 +2051,7 @@ class QueryInfo { // (undocumented) getDiff(): Cache_2.DiffResult; // (undocumented) - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; // (undocumented) init(query: { document: DocumentNode; @@ -2498,11 +2493,15 @@ interface SharedWatchQueryOptions } // @public (undocumented) -export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> extends ExecutionResult { +export interface SingleExecutionResult, TContext = DefaultContext, TExtensions = Record> { // (undocumented) context?: TContext; // (undocumented) data?: TData | null; + // (undocumented) + errors?: ReadonlyArray; + // (undocumented) + extensions?: TExtensions; } // @public (undocumented) diff --git a/.changeset/slimy-berries-yawn.md b/.changeset/slimy-berries-yawn.md new file mode 100644 index 0000000000..ef7d7ec671 --- /dev/null +++ b/.changeset/slimy-berries-yawn.md @@ -0,0 +1,14 @@ +--- +"@apollo/client": minor +--- + +Changes usages of the `GraphQLError` type to `GraphQLFormattedError`. + +This was a type bug - these errors were never `GraphQLError` instances +to begin with, and the `GraphQLError` class has additional properties that can +never be correctly rehydrated from a GraphQL result. +The correct type to use here is `GraphQLFormattedError`. + +Similarly, please ensure to use the type `FormattedExecutionResult` +instead of `ExecutionResult` - the non-"Formatted" versions of these types +are for use on the server only, but don't get transported over the network. diff --git a/.eslintrc b/.eslintrc index b4d6d6f536..e8abca31af 100644 --- a/.eslintrc +++ b/.eslintrc @@ -40,6 +40,22 @@ ], "@typescript-eslint/consistent-type-exports": ["error"], "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/ban-types": [ + "error", + { + "types": { + "GraphQLError": { + "message": "Use GraphQLFormattedError instead", + "fixWith": "GraphQLFormattedError" + }, + "ExecutionResult": { + "message": "Use FormattedExecutionResult instead", + "fixWith": "FormattedExecutionResult" + } + }, + "extendDefaults": false + } + ], "no-restricted-syntax": [ "error", { diff --git a/src/__tests__/client.ts b/src/__tests__/client.ts index cf8df19c26..c16b01d593 100644 --- a/src/__tests__/client.ts +++ b/src/__tests__/client.ts @@ -1,11 +1,11 @@ import { cloneDeep, assign } from "lodash"; import { GraphQLError, - ExecutionResult, DocumentNode, Kind, print, visit, + FormattedExecutionResult, } from "graphql"; import gql from "graphql-tag"; @@ -752,7 +752,7 @@ describe("client", () => { cache: new InMemoryCache({ addTypename: false }), }); - return client.query({ query }).then((result: ExecutionResult) => { + return client.query({ query }).then((result: FormattedExecutionResult) => { expect(result.data).toEqual(data); }); }); @@ -6411,7 +6411,7 @@ function clientRoundtrip( resolve: (result: any) => any, reject: (reason: any) => any, query: DocumentNode, - data: ExecutionResult, + data: FormattedExecutionResult, variables?: any, possibleTypes?: PossibleTypesMap ) { diff --git a/src/core/ApolloClient.ts b/src/core/ApolloClient.ts index 307ea715e8..39fc6f3d50 100644 --- a/src/core/ApolloClient.ts +++ b/src/core/ApolloClient.ts @@ -1,6 +1,6 @@ import { invariant, newInvariantError } from "../utilities/globals/index.js"; -import type { ExecutionResult, DocumentNode } from "graphql"; +import type { DocumentNode, FormattedExecutionResult } from "graphql"; import type { FetchResult, GraphQLRequest } from "../link/core/index.js"; import { ApolloLink, execute } from "../link/core/index.js"; @@ -606,7 +606,9 @@ export class ApolloClient implements DataProxy { this.devToolsHookCb = cb; } - public __requestRaw(payload: GraphQLRequest): Observable { + public __requestRaw( + payload: GraphQLRequest + ): Observable { return execute(this.link, payload); } diff --git a/src/core/QueryInfo.ts b/src/core/QueryInfo.ts index 2e8c149eed..d4058bae2a 100644 --- a/src/core/QueryInfo.ts +++ b/src/core/QueryInfo.ts @@ -1,4 +1,4 @@ -import type { DocumentNode, GraphQLError } from "graphql"; +import type { DocumentNode, GraphQLFormattedError } from "graphql"; import { equal } from "@wry/equality"; import type { Cache, ApolloCache } from "../cache/index.js"; @@ -82,7 +82,7 @@ export class QueryInfo { variables?: Record; networkStatus?: NetworkStatus; networkError?: Error | null; - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; stopped = false; private cache: ApolloCache; diff --git a/src/core/types.ts b/src/core/types.ts index 8085d01383..fefe245b04 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -1,4 +1,4 @@ -import type { DocumentNode, GraphQLError } from "graphql"; +import type { DocumentNode, GraphQLFormattedError } from "graphql"; import type { ApolloCache } from "../cache/index.js"; import type { FetchResult } from "../link/core/index.js"; @@ -145,7 +145,7 @@ export interface ApolloQueryResult { * A list of any errors that occurred during server-side execution of a GraphQL operation. * See https://www.apollographql.com/docs/react/data/error-handling/ for more information. */ - errors?: ReadonlyArray; + errors?: ReadonlyArray; /** * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls. * This will contain both a NetworkError field and any GraphQLErrors. diff --git a/src/errors/__tests__/ApolloError.ts b/src/errors/__tests__/ApolloError.ts index 1881bade23..e672536f66 100644 --- a/src/errors/__tests__/ApolloError.ts +++ b/src/errors/__tests__/ApolloError.ts @@ -1,11 +1,10 @@ import { ApolloError } from ".."; -import { GraphQLError } from "graphql"; describe("ApolloError", () => { it("should construct itself correctly", () => { const graphQLErrors = [ - new GraphQLError("Something went wrong with GraphQL"), - new GraphQLError("Something else went wrong with GraphQL"), + { message: "Something went wrong with GraphQL" }, + { message: "Something else went wrong with GraphQL" }, ]; const protocolErrors = [ { @@ -41,7 +40,7 @@ describe("ApolloError", () => { }); it("should add a graphql error to the message", () => { - const graphQLErrors = [new GraphQLError("this is an error message")]; + const graphQLErrors = [{ message: "this is an error message" }]; const apolloError = new ApolloError({ graphQLErrors, }); @@ -51,8 +50,8 @@ describe("ApolloError", () => { it("should add multiple graphql errors to the message", () => { const graphQLErrors = [ - new GraphQLError("this is new"), - new GraphQLError("this is old"), + { message: "this is new" }, + { message: "this is old" }, ]; const apolloError = new ApolloError({ graphQLErrors, @@ -64,7 +63,7 @@ describe("ApolloError", () => { }); it("should add both network and graphql errors to the message", () => { - const graphQLErrors = [new GraphQLError("graphql error message")]; + const graphQLErrors = [{ message: "graphql error message" }]; const networkError = new Error("network error message"); const apolloError = new ApolloError({ graphQLErrors, @@ -77,7 +76,7 @@ describe("ApolloError", () => { }); it("should add both protocol and graphql errors to the message", () => { - const graphQLErrors = [new GraphQLError("graphql error message")]; + const graphQLErrors = [{ message: "graphql error message" }]; const protocolErrors = [ { message: "cannot read message from websocket", @@ -99,7 +98,7 @@ describe("ApolloError", () => { }); it("should contain a stack trace", () => { - const graphQLErrors = [new GraphQLError("graphql error message")]; + const graphQLErrors = [{ message: "graphql error message" }]; const networkError = new Error("network error message"); const apolloError = new ApolloError({ graphQLErrors, diff --git a/src/errors/index.ts b/src/errors/index.ts index 3c07411161..11a1400773 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -1,6 +1,10 @@ import "../utilities/globals/index.js"; -import type { GraphQLError, GraphQLErrorExtensions } from "graphql"; +import type { + GraphQLError, + GraphQLErrorExtensions, + GraphQLFormattedError, +} from "graphql"; import { isNonNullObject } from "../utilities/index.js"; import type { ServerParseError } from "../link/http/index.js"; @@ -17,7 +21,7 @@ type FetchResultWithSymbolExtensions = FetchResult & { }; export interface ApolloErrorOptions { - graphQLErrors?: ReadonlyArray; + graphQLErrors?: ReadonlyArray; protocolErrors?: ReadonlyArray<{ message: string; extensions?: GraphQLErrorExtensions[]; @@ -67,6 +71,13 @@ const generateErrorMessage = (err: ApolloError) => { ); }; +/** + * @deprecated This type is deprecated and will be removed in the next major version of Apollo Client. + * It mistakenly referenced `GraqhQLError` instead of `GraphQLFormattedError`. + * + * Use `ReadonlyArray` instead. + */ +// eslint-disable-next-line @typescript-eslint/ban-types export type GraphQLErrors = ReadonlyArray; export type NetworkError = Error | ServerParseError | ServerError | null; @@ -74,7 +85,7 @@ export type NetworkError = Error | ServerParseError | ServerError | null; export class ApolloError extends Error { public name: string; public message: string; - public graphQLErrors: GraphQLErrors; + public graphQLErrors: ReadonlyArray; public protocolErrors: ReadonlyArray<{ message: string; extensions?: GraphQLErrorExtensions[]; @@ -88,9 +99,11 @@ export class ApolloError extends Error { */ public cause: | ({ - message: string; - extensions?: GraphQLErrorExtensions[]; - } & Partial) + readonly message: string; + extensions?: + | GraphQLErrorExtensions[] + | GraphQLFormattedError["extensions"]; + } & Omit & Partial, "extensions">) | null; // An object that can be used to provide some additional information @@ -98,8 +111,9 @@ export class ApolloError extends Error { // internally within Apollo Client. public extraInfo: any; - // Constructs an instance of ApolloError given a GraphQLError - // or a network error. Note that one of these has to be a valid + // Constructs an instance of ApolloError given serialized GraphQL errors, + // client errors, protocol errors or network errors. + // Note that one of these has to be a valid // value or the constructed error will be meaningless. constructor({ graphQLErrors, diff --git a/src/link/core/types.ts b/src/link/core/types.ts index a898f1a598..c596ecac0c 100644 --- a/src/link/core/types.ts +++ b/src/link/core/types.ts @@ -1,4 +1,4 @@ -import type { ExecutionResult, GraphQLError } from "graphql"; +import type { GraphQLFormattedError } from "graphql"; import type { DocumentNode } from "graphql"; import type { DefaultContext } from "../../core/index.js"; export type { DocumentNode }; @@ -18,7 +18,7 @@ export interface ExecutionPatchInitialResult< // if data is present, incremental is not data: TData | null | undefined; incremental?: never; - errors?: ReadonlyArray; + errors?: ReadonlyArray; extensions?: TExtensions; } @@ -28,7 +28,7 @@ export interface IncrementalPayload { data: TData | null; label?: string; path: Path; - errors?: ReadonlyArray; + errors?: ReadonlyArray; extensions?: TExtensions; } @@ -91,10 +91,12 @@ export interface SingleExecutionResult< TData = Record, TContext = DefaultContext, TExtensions = Record, -> extends ExecutionResult { +> { // data might be undefined if errorPolicy was set to 'ignore' data?: TData | null; context?: TContext; + errors?: ReadonlyArray; + extensions?: TExtensions; } export type FetchResult< diff --git a/src/link/error/index.ts b/src/link/error/index.ts index 00b0701ab6..bf9494c5df 100644 --- a/src/link/error/index.ts +++ b/src/link/error/index.ts @@ -1,14 +1,14 @@ -import type { ExecutionResult } from "graphql"; +import type { FormattedExecutionResult, GraphQLFormattedError } from "graphql"; -import type { NetworkError, GraphQLErrors } from "../../errors/index.js"; +import type { NetworkError } from "../../errors/index.js"; import { Observable } from "../../utilities/index.js"; import type { Operation, FetchResult, NextLink } from "../core/index.js"; import { ApolloLink } from "../core/index.js"; export interface ErrorResponse { - graphQLErrors?: GraphQLErrors; + graphQLErrors?: ReadonlyArray; networkError?: NetworkError; - response?: ExecutionResult; + response?: FormattedExecutionResult; operation: Operation; forward: NextLink; } diff --git a/src/link/persisted-queries/index.ts b/src/link/persisted-queries/index.ts index 920633bd7f..e631098652 100644 --- a/src/link/persisted-queries/index.ts +++ b/src/link/persisted-queries/index.ts @@ -1,7 +1,11 @@ import { invariant } from "../../utilities/globals/index.js"; import { print } from "../../utilities/index.js"; -import type { DocumentNode, ExecutionResult, GraphQLError } from "graphql"; +import type { + DocumentNode, + FormattedExecutionResult, + GraphQLFormattedError, +} from "graphql"; import type { Operation } from "../core/index.js"; import { ApolloLink } from "../core/index.js"; @@ -21,9 +25,9 @@ import { export const VERSION = 1; export interface ErrorResponse { - graphQLErrors?: readonly GraphQLError[]; + graphQLErrors?: ReadonlyArray; networkError?: NetworkError; - response?: ExecutionResult; + response?: FormattedExecutionResult; operation: Operation; meta: ErrorMeta; } @@ -59,7 +63,10 @@ export namespace PersistedQueryLink { } function processErrors( - graphQLErrors: GraphQLError[] | readonly GraphQLError[] | undefined + graphQLErrors: + | GraphQLFormattedError[] + | ReadonlyArray + | undefined ): ErrorMeta { const byMessage = Object.create(null), byCode = Object.create(null); @@ -165,7 +172,7 @@ export const createPersistedQueryLink = ( const { query } = operation; - return new Observable((observer: Observer) => { + return new Observable((observer: Observer) => { let subscription: ObservableSubscription; let retried = false; let originalFetchOptions: any; @@ -174,13 +181,16 @@ export const createPersistedQueryLink = ( { response, networkError, - }: { response?: ExecutionResult; networkError?: ServerError }, + }: { + response?: FormattedExecutionResult; + networkError?: ServerError; + }, cb: () => void ) => { if (!retried && ((response && response.errors) || networkError)) { retried = true; - const graphQLErrors: GraphQLError[] = []; + const graphQLErrors: GraphQLFormattedError[] = []; const responseErrors = response && response.errors; if (isNonEmptyArray(responseErrors)) { @@ -193,7 +203,7 @@ export const createPersistedQueryLink = ( networkErrors = networkError && networkError.result && - (networkError.result.errors as GraphQLError[]); + (networkError.result.errors as GraphQLFormattedError[]); } if (isNonEmptyArray(networkErrors)) { graphQLErrors.push(...networkErrors); @@ -243,7 +253,7 @@ export const createPersistedQueryLink = ( cb(); }; const handler = { - next: (response: ExecutionResult) => { + next: (response: FormattedExecutionResult) => { maybeRetry({ response }, () => observer.next!(response)); }, error: (networkError: ServerError) => { diff --git a/src/link/subscriptions/index.ts b/src/link/subscriptions/index.ts index db56154718..4823f7a22e 100644 --- a/src/link/subscriptions/index.ts +++ b/src/link/subscriptions/index.ts @@ -29,12 +29,13 @@ // THE SOFTWARE. import { print } from "../../utilities/index.js"; -import type { Client } from "graphql-ws"; +import type { Client, Sink } from "graphql-ws"; import type { Operation, FetchResult } from "../core/index.js"; import { ApolloLink } from "../core/index.js"; import { isNonNullObject, Observable } from "../../utilities/index.js"; import { ApolloError } from "../../errors/index.js"; +import type { FormattedExecutionResult } from "graphql"; // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event function isLikeCloseEvent(val: unknown): val is CloseEvent { @@ -80,7 +81,8 @@ export class GraphQLWsLink extends ApolloLink { }) ); }, - } + // casting around a wrong type in graphql-ws, which incorrectly expects `Sink` + } satisfies Sink as any ); }); } diff --git a/src/react/components/__tests__/client/Mutation.test.tsx b/src/react/components/__tests__/client/Mutation.test.tsx index b71ba82f7c..fc88f76b44 100644 --- a/src/react/components/__tests__/client/Mutation.test.tsx +++ b/src/react/components/__tests__/client/Mutation.test.tsx @@ -1,6 +1,10 @@ import React, { useState, PropsWithChildren } from "react"; import gql from "graphql-tag"; -import { ExecutionResult, GraphQLError } from "graphql"; +import { + ExecutionResult, + FormattedExecutionResult, + GraphQLError, +} from "graphql"; import userEvent from "@testing-library/user-event"; import { render, screen, waitFor, act } from "@testing-library/react"; @@ -1195,7 +1199,7 @@ describe("General Mutation testing", () => { })); it("has an update prop for updating the store after the mutation", async () => { - const update = (_proxy: DataProxy, response: ExecutionResult) => { + const update = (_proxy: DataProxy, response: FormattedExecutionResult) => { expect(response.data).toEqual(data); }; diff --git a/src/testing/experimental/createSchemaFetch.ts b/src/testing/experimental/createSchemaFetch.ts index 5c03ea0da0..fe253f9889 100644 --- a/src/testing/experimental/createSchemaFetch.ts +++ b/src/testing/experimental/createSchemaFetch.ts @@ -1,5 +1,5 @@ import { execute, validate } from "graphql"; -import type { GraphQLError, GraphQLSchema } from "graphql"; +import type { GraphQLFormattedError, GraphQLSchema } from "graphql"; import { ApolloError, gql } from "../../core/index.js"; import { withCleanup } from "../internal/index.js"; import { wait } from "../core/wait.js"; @@ -67,7 +67,16 @@ const createSchemaFetch = ( validationErrors = validate(schema, document); } catch (e) { validationErrors = [ - new ApolloError({ graphQLErrors: [e as GraphQLError] }), + new ApolloError({ + graphQLErrors: [ + /* + * Technically, these are even `GraphQLError` instances, + * but we try to avoid referencing that type, and `GraphQLError` + * implements the `GraphQLFormattedError` interface. + */ + e as GraphQLFormattedError, + ], + }), ]; }