From 3cb5bc51ddc5e7634cf30043e3cb88c1a69dfd17 Mon Sep 17 00:00:00 2001 From: Rando Luik Date: Thu, 28 May 2026 11:42:20 +0300 Subject: [PATCH 1/3] Fix error format --- .../lib/services/graphql/graphql.service.ts | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/javascript-api/src/lib/services/graphql/graphql.service.ts b/packages/javascript-api/src/lib/services/graphql/graphql.service.ts index b030ee8d..9c63fc29 100644 --- a/packages/javascript-api/src/lib/services/graphql/graphql.service.ts +++ b/packages/javascript-api/src/lib/services/graphql/graphql.service.ts @@ -37,14 +37,14 @@ function parseQuery(queryOrDocumentNode: string | DocumentNode): string { throw new Error('queryOrDocumentNode must be a string or a DocumentNode'); } -export interface QminderGraphQLError { - message: string; - errorType?: string | null; - extensions?: GraphQLErrorExtensions | null; - sourcePreview?: string | null; - offendingToken?: string | null; - locations?: SourceLocation[] | null; - path?: (string | number)[] | null; +interface QminderGraphQLError { + readonly message: string; + readonly errorType?: string | null; + readonly extensions?: GraphQLErrorExtensions | null; + readonly sourcePreview?: string | null; + readonly offendingToken?: string | null; + readonly locations?: SourceLocation[] | null; + readonly path?: (string | number)[] | null; } interface Message { @@ -756,11 +756,12 @@ export class GraphqlService { const subscriber = this.messagesSubscribers.get(messageId); this.cleanUpSubscription(messageId); - subscriber?.error( - new Error( - `Subscription failed after ${this.retryableErroredSubscriptionsRetryCount} retries`, - ), - ); + subscriber?.error([ + { + message: `Subscription failed after ${this.retryableErroredSubscriptionsRetryCount} retries`, + errorType: 'ERROR', + }, + ] satisfies QminderGraphQLError[]); } }); } From abe8a3ab3c3e04426f33abed44235dece2fc564c Mon Sep 17 00:00:00 2001 From: Rando Luik Date: Thu, 28 May 2026 11:45:10 +0300 Subject: [PATCH 2/3] Revert change --- .../javascript-api/src/lib/services/graphql/graphql.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/javascript-api/src/lib/services/graphql/graphql.service.ts b/packages/javascript-api/src/lib/services/graphql/graphql.service.ts index 9c63fc29..8d5ed614 100644 --- a/packages/javascript-api/src/lib/services/graphql/graphql.service.ts +++ b/packages/javascript-api/src/lib/services/graphql/graphql.service.ts @@ -37,7 +37,7 @@ function parseQuery(queryOrDocumentNode: string | DocumentNode): string { throw new Error('queryOrDocumentNode must be a string or a DocumentNode'); } -interface QminderGraphQLError { +export interface QminderGraphQLError { readonly message: string; readonly errorType?: string | null; readonly extensions?: GraphQLErrorExtensions | null; From d7f8ebcf68f2f49a3dd604ab01d3697051191ae9 Mon Sep 17 00:00:00 2001 From: Rando Luik Date: Thu, 28 May 2026 11:49:58 +0300 Subject: [PATCH 3/3] Fix unit tests --- .../__tests__/graphql-subscriptions.spec.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/javascript-api/src/lib/services/graphql/__tests__/graphql-subscriptions.spec.ts b/packages/javascript-api/src/lib/services/graphql/__tests__/graphql-subscriptions.spec.ts index 5769301f..bc642763 100644 --- a/packages/javascript-api/src/lib/services/graphql/__tests__/graphql-subscriptions.spec.ts +++ b/packages/javascript-api/src/lib/services/graphql/__tests__/graphql-subscriptions.spec.ts @@ -898,17 +898,23 @@ describe('GraphQL subscriptions', () => { sendErrorMessages(); } - expect(subscriptionErrorSpy).toHaveBeenCalledWith( - expect.objectContaining({ + expect(subscriptionErrorSpy).toHaveBeenCalledWith< + [QminderGraphQLError[]] + >([ + { message: 'Subscription failed after 5 retries', - }), - ); + errorType: 'ERROR', + }, + ] satisfies QminderGraphQLError[]); - expect(subscription2ErrorSpy).toHaveBeenCalledWith( - expect.objectContaining({ + expect(subscription2ErrorSpy).toHaveBeenCalledWith< + [QminderGraphQLError[]] + >([ + { message: 'Subscription failed after 5 retries', - }), - ); + errorType: 'ERROR', + }, + ]); subscription.unsubscribe(); subscription2.unsubscribe();