Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 13 additions & 12 deletions packages/javascript-api/src/lib/services/graphql/graphql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ function parseQuery(queryOrDocumentNode: string | DocumentNode): string {
}

export interface QminderGraphQLError {
message: string;
errorType?: string | null;
extensions?: GraphQLErrorExtensions | null;
sourcePreview?: string | null;
offendingToken?: string | null;
locations?: SourceLocation[] | null;
path?: (string | number)[] | null;
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 {
Expand Down Expand Up @@ -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',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: we don't need to add this to nonretryable errors array right?
there is no way this one could be received from the socket

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This is never sent from the back-end.

},
] satisfies QminderGraphQLError[]);
}
});
}
Expand Down
Loading