Make result type generic on ApolloOperationErrorHandlerFunction

This commit is contained in:
Simon Garner
2021-10-28 16:30:48 +13:00
parent 6923ead0e6
commit 05ec76bf91
2 changed files with 9 additions and 7 deletions
+7 -6
View File
@@ -2,16 +2,17 @@ import { processApolloError } from './processApolloError';
import { ApolloOperationContext } from '../types';
import { Vue } from 'vue/types/vue';
import { ApolloError, ApolloOperationErrorHandlerFunction } from './types';
import { ApolloErrorHandlerResult, ApolloErrorHandlerResultInterface } from './ApolloErrorHandlerResult';
import { ApolloErrorHandlerResult } from './ApolloErrorHandlerResult';
/**
* This is a simple example of an error handler function. You can copy this and implement your own in your application.
*/
export const handleApolloError: ApolloOperationErrorHandlerFunction<ApolloError, Vue> = (
error: ApolloError,
app: Vue,
context?: ApolloOperationContext,
): ApolloErrorHandlerResultInterface => {
export const handleApolloError: ApolloOperationErrorHandlerFunction<
ApolloError,
Vue,
ApolloOperationContext,
ApolloErrorHandlerResult
> = (error: ApolloError, app: Vue, context?: ApolloOperationContext): ApolloErrorHandlerResult => {
const { unhandledErrors, handledErrors } = processApolloError(error, {
app,
context,
+2 -1
View File
@@ -83,4 +83,5 @@ export type ApolloOperationErrorHandlerFunction<
TError = BaseApolloError,
TApp extends Vue = Vue,
TContext = ApolloOperationContext,
> = (error: TError, app: TApp, context?: TContext) => ApolloErrorHandlerResultInterface;
TResult = ApolloErrorHandlerResultInterface,
> = (error: TError, app: TApp, context?: TContext) => TResult;