You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a static `is` method to error types defined by Apollo Client. `is` makes it simpler to determine whether an error is a specific type, which can be helpful in cases where you'd like to narrow the error type in order to use specific properties from that error.
Copy file name to clipboardExpand all lines: src/errors/CombinedProtocolErrors.ts
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,18 @@
1
1
importtype{GraphQLFormattedError}from"graphql";
2
2
3
+
import{brand,isBranded}from"./utils.js";
4
+
3
5
/**
4
6
* Fatal transport-level errors returned when executing a subscription using the
5
7
* multipart HTTP subscription protocol. See the documentation on the
6
8
* [multipart HTTP protocol for GraphQL Subscriptions](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol) for more information on these errors.
7
9
*/
8
10
exportclassCombinedProtocolErrorsextendsError{
11
+
/** Determine if an error is a `CombinedProtocolErrors` instance */
12
+
staticis(error: unknown): error is CombinedProtocolErrors{
13
+
returnisBranded(error,"CombinedProtocolErrors");
14
+
}
15
+
9
16
errors: ReadonlyArray<GraphQLFormattedError>;
10
17
11
18
constructor(
@@ -17,6 +24,7 @@ export class CombinedProtocolErrors extends Error {
0 commit comments