Skip to content

Commit daa4f33

Browse files
authoredJan 30, 2025··
Fix type of extensions in protocolErrors (#12321)
1 parent 5ae1215 commit daa4f33

20 files changed

+65
-173
lines changed
 

‎.api-reports/api-report-core.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ export class ApolloError extends Error {
200200
// (undocumented)
201201
networkError: Error | ServerParseError | ServerError | null;
202202
// (undocumented)
203-
protocolErrors: ReadonlyArray<{
204-
message: string;
205-
extensions?: GraphQLErrorExtensions[];
206-
}>;
203+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
207204
}
208205

209206
// @public (undocumented)
@@ -219,10 +216,7 @@ interface ApolloErrorOptions {
219216
// (undocumented)
220217
networkError?: Error | ServerParseError | ServerError | null;
221218
// (undocumented)
222-
protocolErrors?: ReadonlyArray<{
223-
message: string;
224-
extensions?: GraphQLErrorExtensions[];
225-
}>;
219+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
226220
}
227221

228222
// @public (undocumented)

‎.api-reports/api-report-errors.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ export class ApolloError extends Error {
3131
// (undocumented)
3232
networkError: Error | ServerParseError | ServerError | null;
3333
// (undocumented)
34-
protocolErrors: ReadonlyArray<{
35-
message: string;
36-
extensions?: GraphQLErrorExtensions[];
37-
}>;
34+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
3835
}
3936

4037
// @public (undocumented)
@@ -50,10 +47,7 @@ export interface ApolloErrorOptions {
5047
// (undocumented)
5148
networkError?: Error | ServerParseError | ServerError | null;
5249
// (undocumented)
53-
protocolErrors?: ReadonlyArray<{
54-
message: string;
55-
extensions?: GraphQLErrorExtensions[];
56-
}>;
50+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
5751
}
5852

5953
// @public (undocumented)

‎.api-reports/api-report-link_error.api.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import type { DocumentNode } from 'graphql';
88
import type { FormattedExecutionResult } from 'graphql';
9-
import type { GraphQLErrorExtensions } from 'graphql';
109
import type { GraphQLFormattedError } from 'graphql';
1110
import { Observable } from 'zen-observable-ts';
1211
import type { Observer } from 'zen-observable-ts';
@@ -86,10 +85,7 @@ export interface ErrorResponse {
8685
networkError?: NetworkError;
8786
// (undocumented)
8887
operation: Operation;
89-
protocolErrors?: ReadonlyArray<{
90-
message: string;
91-
extensions?: GraphQLErrorExtensions[];
92-
}>;
88+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
9389
// (undocumented)
9490
response?: FormattedExecutionResult;
9591
}

‎.api-reports/api-report-react.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ class ApolloError extends Error {
257257
// (undocumented)
258258
networkError: Error | ServerParseError | ServerError | null;
259259
// (undocumented)
260-
protocolErrors: ReadonlyArray<{
261-
message: string;
262-
extensions?: GraphQLErrorExtensions[];
263-
}>;
260+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
264261
}
265262

266263
// @public (undocumented)
@@ -276,10 +273,7 @@ interface ApolloErrorOptions {
276273
// (undocumented)
277274
networkError?: Error | ServerParseError | ServerError | null;
278275
// (undocumented)
279-
protocolErrors?: ReadonlyArray<{
280-
message: string;
281-
extensions?: GraphQLErrorExtensions[];
282-
}>;
276+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
283277
}
284278

285279
// @public (undocumented)

‎.api-reports/api-report-react_components.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,7 @@ class ApolloError extends Error {
235235
// (undocumented)
236236
networkError: Error | ServerParseError | ServerError | null;
237237
// (undocumented)
238-
protocolErrors: ReadonlyArray<{
239-
message: string;
240-
extensions?: GraphQLErrorExtensions[];
241-
}>;
238+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
242239
}
243240

244241
// @public (undocumented)
@@ -254,10 +251,7 @@ interface ApolloErrorOptions {
254251
// (undocumented)
255252
networkError?: Error | ServerParseError | ServerError | null;
256253
// (undocumented)
257-
protocolErrors?: ReadonlyArray<{
258-
message: string;
259-
extensions?: GraphQLErrorExtensions[];
260-
}>;
254+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
261255
}
262256

263257
// @public (undocumented)

‎.api-reports/api-report-react_context.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,7 @@ class ApolloError extends Error {
255255
// (undocumented)
256256
networkError: Error | ServerParseError | ServerError | null;
257257
// (undocumented)
258-
protocolErrors: ReadonlyArray<{
259-
message: string;
260-
extensions?: GraphQLErrorExtensions[];
261-
}>;
258+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
262259
}
263260

264261
// @public (undocumented)
@@ -274,10 +271,7 @@ interface ApolloErrorOptions {
274271
// (undocumented)
275272
networkError?: Error | ServerParseError | ServerError | null;
276273
// (undocumented)
277-
protocolErrors?: ReadonlyArray<{
278-
message: string;
279-
extensions?: GraphQLErrorExtensions[];
280-
}>;
274+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
281275
}
282276

283277
// @public (undocumented)

‎.api-reports/api-report-react_hoc.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ class ApolloError extends Error {
234234
// (undocumented)
235235
networkError: Error | ServerParseError | ServerError | null;
236236
// (undocumented)
237-
protocolErrors: ReadonlyArray<{
238-
message: string;
239-
extensions?: GraphQLErrorExtensions[];
240-
}>;
237+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
241238
}
242239

243240
// @public (undocumented)
@@ -253,10 +250,7 @@ interface ApolloErrorOptions {
253250
// (undocumented)
254251
networkError?: Error | ServerParseError | ServerError | null;
255252
// (undocumented)
256-
protocolErrors?: ReadonlyArray<{
257-
message: string;
258-
extensions?: GraphQLErrorExtensions[];
259-
}>;
253+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
260254
}
261255

262256
// @public (undocumented)

‎.api-reports/api-report-react_hooks.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ class ApolloError extends Error {
233233
// (undocumented)
234234
networkError: Error | ServerParseError | ServerError | null;
235235
// (undocumented)
236-
protocolErrors: ReadonlyArray<{
237-
message: string;
238-
extensions?: GraphQLErrorExtensions[];
239-
}>;
236+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
240237
}
241238

242239
// @public (undocumented)
@@ -252,10 +249,7 @@ interface ApolloErrorOptions {
252249
// (undocumented)
253250
networkError?: Error | ServerParseError | ServerError | null;
254251
// (undocumented)
255-
protocolErrors?: ReadonlyArray<{
256-
message: string;
257-
extensions?: GraphQLErrorExtensions[];
258-
}>;
252+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
259253
}
260254

261255
// @public (undocumented)

‎.api-reports/api-report-react_internal.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ class ApolloError extends Error {
233233
// (undocumented)
234234
networkError: Error | ServerParseError | ServerError | null;
235235
// (undocumented)
236-
protocolErrors: ReadonlyArray<{
237-
message: string;
238-
extensions?: GraphQLErrorExtensions[];
239-
}>;
236+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
240237
}
241238

242239
// @public (undocumented)
@@ -252,10 +249,7 @@ interface ApolloErrorOptions {
252249
// (undocumented)
253250
networkError?: Error | ServerParseError | ServerError | null;
254251
// (undocumented)
255-
protocolErrors?: ReadonlyArray<{
256-
message: string;
257-
extensions?: GraphQLErrorExtensions[];
258-
}>;
252+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
259253
}
260254

261255
// @public (undocumented)

‎.api-reports/api-report-react_ssr.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ class ApolloError extends Error {
234234
// (undocumented)
235235
networkError: Error | ServerParseError | ServerError | null;
236236
// (undocumented)
237-
protocolErrors: ReadonlyArray<{
238-
message: string;
239-
extensions?: GraphQLErrorExtensions[];
240-
}>;
237+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
241238
}
242239

243240
// @public (undocumented)
@@ -253,10 +250,7 @@ interface ApolloErrorOptions {
253250
// (undocumented)
254251
networkError?: Error | ServerParseError | ServerError | null;
255252
// (undocumented)
256-
protocolErrors?: ReadonlyArray<{
257-
message: string;
258-
extensions?: GraphQLErrorExtensions[];
259-
}>;
253+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
260254
}
261255

262256
// @public (undocumented)

‎.api-reports/api-report-testing.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ class ApolloError extends Error {
234234
// (undocumented)
235235
networkError: Error | ServerParseError | ServerError | null;
236236
// (undocumented)
237-
protocolErrors: ReadonlyArray<{
238-
message: string;
239-
extensions?: GraphQLErrorExtensions[];
240-
}>;
237+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
241238
}
242239

243240
// @public (undocumented)
@@ -253,10 +250,7 @@ interface ApolloErrorOptions {
253250
// (undocumented)
254251
networkError?: Error | ServerParseError | ServerError | null;
255252
// (undocumented)
256-
protocolErrors?: ReadonlyArray<{
257-
message: string;
258-
extensions?: GraphQLErrorExtensions[];
259-
}>;
253+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
260254
}
261255

262256
// @public (undocumented)

‎.api-reports/api-report-testing_core.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ class ApolloError extends Error {
233233
// (undocumented)
234234
networkError: Error | ServerParseError | ServerError | null;
235235
// (undocumented)
236-
protocolErrors: ReadonlyArray<{
237-
message: string;
238-
extensions?: GraphQLErrorExtensions[];
239-
}>;
236+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
240237
}
241238

242239
// @public (undocumented)
@@ -252,10 +249,7 @@ interface ApolloErrorOptions {
252249
// (undocumented)
253250
networkError?: Error | ServerParseError | ServerError | null;
254251
// (undocumented)
255-
protocolErrors?: ReadonlyArray<{
256-
message: string;
257-
extensions?: GraphQLErrorExtensions[];
258-
}>;
252+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
259253
}
260254

261255
// @public (undocumented)

‎.api-reports/api-report-utilities.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@ class ApolloError extends Error {
248248
// (undocumented)
249249
networkError: Error | ServerParseError | ServerError | null;
250250
// (undocumented)
251-
protocolErrors: ReadonlyArray<{
252-
message: string;
253-
extensions?: GraphQLErrorExtensions[];
254-
}>;
251+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
255252
}
256253

257254
// @public (undocumented)
@@ -267,10 +264,7 @@ interface ApolloErrorOptions {
267264
// (undocumented)
268265
networkError?: Error | ServerParseError | ServerError | null;
269266
// (undocumented)
270-
protocolErrors?: ReadonlyArray<{
271-
message: string;
272-
extensions?: GraphQLErrorExtensions[];
273-
}>;
267+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
274268
}
275269

276270
// @public (undocumented)

‎.api-reports/api-report.api.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ export class ApolloError extends Error {
223223
// (undocumented)
224224
networkError: Error | ServerParseError | ServerError | null;
225225
// (undocumented)
226-
protocolErrors: ReadonlyArray<{
227-
message: string;
228-
extensions?: GraphQLErrorExtensions[];
229-
}>;
226+
protocolErrors: ReadonlyArray<GraphQLFormattedError>;
230227
}
231228

232229
// @public (undocumented)
@@ -242,10 +239,7 @@ interface ApolloErrorOptions {
242239
// (undocumented)
243240
networkError?: Error | ServerParseError | ServerError | null;
244241
// (undocumented)
245-
protocolErrors?: ReadonlyArray<{
246-
message: string;
247-
extensions?: GraphQLErrorExtensions[];
248-
}>;
242+
protocolErrors?: ReadonlyArray<GraphQLFormattedError>;
249243
}
250244

251245
// @public (undocumented)

‎.changeset/curvy-seahorses-walk.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Fix type of `extensions` in `protocolErrors` for `ApolloError` and the `onError` link. According to the [multipart HTTP subscription protocol](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol), fatal tranport errors follow the [GraphQL error format](https://spec.graphql.org/draft/#sec-Errors.Error-Result-Format) which require `extensions` to be a map as its value instead of an array.

‎src/__tests__/__snapshots__/graphqlSubscriptions.ts.snap

+6-10
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ ApolloError {
4040
exports[`GraphQL Subscriptions should throw an error if the result has protocolErrors on it 1`] = `
4141
ApolloError {
4242
"cause": Object {
43-
"extensions": Array [
44-
Object {
45-
"code": "WEBSOCKET_MESSAGE_ERROR",
46-
},
47-
],
43+
"extensions": Object {
44+
"code": "WEBSOCKET_MESSAGE_ERROR",
45+
},
4846
"message": "cannot read message from websocket",
4947
},
5048
"clientErrors": Array [],
@@ -55,11 +53,9 @@ ApolloError {
5553
"networkError": null,
5654
"protocolErrors": Array [
5755
Object {
58-
"extensions": Array [
59-
Object {
60-
"code": "WEBSOCKET_MESSAGE_ERROR",
61-
},
62-
],
56+
"extensions": Object {
57+
"code": "WEBSOCKET_MESSAGE_ERROR",
58+
},
6359
"message": "cannot read message from websocket",
6460
},
6561
],

0 commit comments

Comments
 (0)
Please sign in to comment.