Skip to content

Commit

Permalink
Merge branch 'main' into release-4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Jan 22, 2025
2 parents d1ba516 + de8196e commit 400e4e9
Show file tree
Hide file tree
Showing 40 changed files with 1,440 additions and 843 deletions.
4 changes: 2 additions & 2 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ export class ApolloLink {
// @public (undocumented)
export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
// (undocumented)
errors?: ReadonlyArray<Error | string>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
payload: SingleExecutionResult | ExecutionPatchResult | null;
payload: SingleExecutionResult<TData, DefaultContext, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
}

// @public (undocumented)
Expand Down
8 changes: 4 additions & 4 deletions .api-reports/api-report-link_core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export class ApolloLink {
// @public (undocumented)
export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
// (undocumented)
errors?: ReadonlyArray<Error | string>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts
//
// (undocumented)
payload: SingleExecutionResult | ExecutionPatchResult | null;
payload: SingleExecutionResult<TData, DefaultContext, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
}

// @public (undocumented)
Expand Down Expand Up @@ -106,8 +108,6 @@ export const from: typeof ApolloLink.from;

// @public (undocumented)
export interface GraphQLRequest<TVariables = Record<string, any>> {
// Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts
//
// (undocumented)
context?: DefaultContext;
// (undocumented)
Expand Down
8 changes: 5 additions & 3 deletions .api-reports/api-report-link_error.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import type { DocumentNode } from 'graphql';
import type { FormattedExecutionResult } 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';
Expand Down Expand Up @@ -80,14 +81,15 @@ export class ErrorLink extends ApolloLink {
export interface ErrorResponse {
// (undocumented)
forward: NextLink;
// (undocumented)
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
// Warning: (ae-forgotten-export) The symbol "NetworkError" needs to be exported by the entry point index.d.ts
//
// (undocumented)
networkError?: NetworkError;
// (undocumented)
operation: Operation;
protocolErrors?: ReadonlyArray<{
message: string;
extensions?: GraphQLErrorExtensions[];
}>;
// (undocumented)
response?: FormattedExecutionResult;
}
Expand Down
4 changes: 2 additions & 2 deletions .api-reports/api-report-link_persisted-queries.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interface BaseOptions {
// Warning: (ae-forgotten-export) The symbol "ApolloLink" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export const createPersistedQueryLink: (options: PersistedQueryLink.Options) => ApolloLink & {
export const createPersistedQueryLink: (options: PersistedQueryLink.Options) => ApolloLink & ({
resetHashCache: () => void;
} & ({
getMemoryInternals(): {
Expand All @@ -73,7 +73,7 @@ export const createPersistedQueryLink: (options: PersistedQueryLink.Options) =>
};
} | {
getMemoryInternals?: undefined;
});
}));

// @public (undocumented)
interface DefaultContext extends Record<string, any> {
Expand Down
4 changes: 2 additions & 2 deletions .api-reports/api-report-utilities.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ class ApolloLink {
// @public (undocumented)
interface ApolloPayloadResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
// (undocumented)
errors?: ReadonlyArray<Error | string>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// Warning: (ae-forgotten-export) The symbol "SingleExecutionResult" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ExecutionPatchResult" needs to be exported by the entry point index.d.ts
//
// (undocumented)
payload: SingleExecutionResult | ExecutionPatchResult | null;
payload: SingleExecutionResult<TData, DefaultContext, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
}

// @public (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions .api-reports/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ export class ApolloLink {
// @public (undocumented)
export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
// (undocumented)
errors?: ReadonlyArray<Error | string>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
payload: SingleExecutionResult | ExecutionPatchResult | null;
payload: SingleExecutionResult<TData, DefaultContext, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
}

// Warning: (ae-forgotten-export) The symbol "ApolloProviderProps" needs to be exported by the entry point index.d.ts
Expand Down
105 changes: 0 additions & 105 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 41561,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 34389
"dist/apollo-client.min.cjs": 41586,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 34415
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# @apollo/client

## 3.12.7

### Patch Changes

- [#12281](https://github.com/apollographql/apollo-client/pull/12281) [`d638ec3`](https://github.com/apollographql/apollo-client/commit/d638ec317b7d21c2246251ef1b9d773588277b39) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Make fatal [tranport-level errors](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol#message-and-error-format) from multipart subscriptions available to the error link with the `protocolErrors` property.

```js
const errorLink = onError(({ protocolErrors }) => {
if (protocolErrors) {
console.log(protocolErrors);
}
});
```

- [#12281](https://github.com/apollographql/apollo-client/pull/12281) [`d638ec3`](https://github.com/apollographql/apollo-client/commit/d638ec317b7d21c2246251ef1b9d773588277b39) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the array type for the `errors` field on the `ApolloPayloadResult` type. This type was always in the shape of the GraphQL error format, per the [multipart subscriptions protocol](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol#message-and-error-format) and never a plain string or a JavaScript error object.

## 3.12.6

### Patch Changes
Expand Down
27 changes: 25 additions & 2 deletions docs/source/api/link/apollo-link-error.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@ Use the `onError` link to perform custom logic when a [GraphQL or network error]
```js
import { onError } from "@apollo/client/link/error";

// Log any GraphQL errors or network error that occurred
const errorLink = onError(({ graphQLErrors, networkError }) => {
// Log any GraphQL errors, protocol errors, or network error that occurred
const errorLink = onError(({ graphQLErrors, networkError, protocolErrors }) => {
if (graphQLErrors)
graphQLErrors.forEach(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
);

if (protocolErrors) {
protocolErrors.forEach(({ message, extensions }) => {
console.log(
`[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(extensions)}`
);
});
}

if (networkError) console.log(`[Network error]: ${networkError}`);
});
```
Expand Down Expand Up @@ -100,6 +109,20 @@ A network error that occurred while attempting to execute the operation, if any.
</td>
</tr>

<tr>
<td>

###### `protocolErrors`

`ReadonlyArray<{ message: string; extensions?: GraphQLErrorExtensions[]; }>`
</td>
<td>

Fatal transport-level errors from multipart subscriptions. See the [multipart subscription protocol](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol#message-and-error-format) for more information.

</td>
</tr>


<tr>
<td>
Expand Down
11 changes: 7 additions & 4 deletions eslint-local-rules/testSetup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RuleTester } from "@typescript-eslint/rule-tester";
import tsParser from "@typescript-eslint/parser";
import nodeTest from "node:test";

RuleTester.it = nodeTest.it;
Expand All @@ -7,9 +8,11 @@ RuleTester.describe = nodeTest.describe;
RuleTester.afterAll = nodeTest.after;

export const ruleTester = new RuleTester({
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname + "/fixtures",
languageOptions: {
parser: tsParser,
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname + "/fixtures",
},
},
});
Loading

0 comments on commit 400e4e9

Please sign in to comment.