From f4400ac8afbf5482e1263c60ed3e0278b59dabf3 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Wed, 10 Oct 2018 16:17:10 +0200 Subject: [PATCH] Rename dispatcher methods to clarify they invoke hooks --- packages/apollo-server-core/src/requestPipeline.ts | 10 +++++----- packages/apollo-server-core/src/utils/dispatcher.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/apollo-server-core/src/requestPipeline.ts b/packages/apollo-server-core/src/requestPipeline.ts index 8526d777..1fa004ef 100644 --- a/packages/apollo-server-core/src/requestPipeline.ts +++ b/packages/apollo-server-core/src/requestPipeline.ts @@ -184,7 +184,7 @@ export class GraphQLRequestPipeline { persistedQueryRegister, }); - const parsingDidEnd = await dispatcher.invokeDidStart( + const parsingDidEnd = await dispatcher.invokeDidStartHook( 'parsingDidStart', requestContext, ); @@ -207,7 +207,7 @@ export class GraphQLRequestPipeline { requestContext.document = document; - const validationDidEnd = await dispatcher.invokeDidStart( + const validationDidEnd = await dispatcher.invokeDidStartHook( 'validationDidStart', requestContext as WithRequired, ); @@ -238,7 +238,7 @@ export class GraphQLRequestPipeline { requestContext.operationName = (operation && operation.name && operation.name.value) || null; - await dispatcher.invokeAsync( + await dispatcher.invokeHookAsync( 'didResolveOperation', requestContext as WithRequired< typeof requestContext, @@ -246,7 +246,7 @@ export class GraphQLRequestPipeline { >, ); - const executionDidEnd = await dispatcher.invokeDidStart( + const executionDidEnd = await dispatcher.invokeDidStartHook( 'executionDidStart', requestContext as WithRequired< typeof requestContext, @@ -355,7 +355,7 @@ export class GraphQLRequestPipeline { extensions: response.extensions, }, }).graphqlResponse; - await dispatcher.invokeAsync( + await dispatcher.invokeHookAsync( 'willSendResponse', requestContext as WithRequired, ); diff --git a/packages/apollo-server-core/src/utils/dispatcher.ts b/packages/apollo-server-core/src/utils/dispatcher.ts index b305830a..c2748a65 100644 --- a/packages/apollo-server-core/src/utils/dispatcher.ts +++ b/packages/apollo-server-core/src/utils/dispatcher.ts @@ -11,7 +11,7 @@ type DidEndHook = (...args: TArgs) => void; export class Dispatcher { constructor(protected targets: T[]) {} - public async invokeAsync< + public async invokeHookAsync< TMethodName extends FunctionPropertyNames> >( methodName: TMethodName, @@ -27,7 +27,7 @@ export class Dispatcher { ); } - public invokeDidStart< + public invokeDidStartHook< TMethodName extends FunctionPropertyNames< Required, ((...args: any[]) => AnyFunction | void)