import { Middleware , ResolverContext } from './Middleware' ; import { ExecutionContext } from '../execution/ExecutionContext' ; import { GraphQLScalarType } from 'graphql/type' ; export class Suffixer implements Middleware < Map < string , number > , number , mixed > { constructor ( private suffix ) { } public beforeQuery ( ) { return new Map < string , number > ( ) ; } public afterField ( _mVal , _fValue , value , _eCtx , mCtx ) { const returnType = mCtx . info . returnType ; if ( returnType instanceof GraphQLScalarType && returnType . name === 'String' ) { return `${ value }${ this . suffix }` ; } return ; } }