@@ -38,24 +38,24 @@ export const gqlResolverDuration = new client.Histogram({
3838 * Apollo Server plugin to track GraphQL metrics
3939 */
4040export const graphqlMetricsPlugin : ApolloServerPlugin = {
41- async requestDidStart ( requestContext : GraphQLRequestContext ) : Promise < GraphQLRequestListener > {
41+ async requestDidStart ( _requestContext : GraphQLRequestContext ) : Promise < GraphQLRequestListener > {
4242 const startTime = Date . now ( ) ;
4343 let operationName = 'unknown' ;
4444 let operationType = 'unknown' ;
4545
4646 return {
47- async didResolveOperation ( requestContext : GraphQLRequestContext ) {
48- operationName = requestContext . operationName || 'anonymous' ;
49- operationType = requestContext . operation ?. operation || 'unknown' ;
47+ async didResolveOperation ( ctx : GraphQLRequestContext ) : Promise < void > {
48+ operationName = ctx . operationName || 'anonymous' ;
49+ operationType = ctx . operation ?. operation || 'unknown' ;
5050 } ,
5151
52- async executionDidStart ( ) {
52+ async executionDidStart ( ) : Promise < GraphQLRequestListener > {
5353 return {
5454 // eslint-disable-next-line @typescript-eslint/no-explicit-any
55- willResolveField ( { info } : any ) {
55+ willResolveField ( { info } : any ) : ( ) => void {
5656 const fieldStartTime = Date . now ( ) ;
5757
58- return ( ) => {
58+ return ( ) : void => {
5959 const duration = ( Date . now ( ) - fieldStartTime ) / 1000 ;
6060
6161 gqlResolverDuration
@@ -70,16 +70,16 @@ export const graphqlMetricsPlugin: ApolloServerPlugin = {
7070 } ;
7171 } ,
7272
73- async willSendResponse ( requestContext : GraphQLRequestContext ) {
73+ async willSendResponse ( ctx : GraphQLRequestContext ) : Promise < void > {
7474 const duration = ( Date . now ( ) - startTime ) / 1000 ;
7575
7676 gqlOperationDuration
7777 . labels ( operationName , operationType )
7878 . observe ( duration ) ;
7979
8080 // Track errors if any
81- if ( requestContext . errors && requestContext . errors . length > 0 ) {
82- requestContext . errors . forEach ( ( error : GraphQLError ) => {
81+ if ( ctx . errors && ctx . errors . length > 0 ) {
82+ ctx . errors . forEach ( ( error : GraphQLError ) => {
8383 const errorType = error . extensions ?. code || error . name || 'unknown' ;
8484
8585 gqlOperationErrors
0 commit comments