import { authenticated } from './authenticated-resolver' ; import { SchemaDirectiveVisitor } from '@graphql-tools/utils' ; export class AuthenticatedDirective extends SchemaDirectiveVisitor { public visitFieldDefinition ( field ) { field . resolve = authenticated ( field . resolve ) ; } public visitObject ( object ) { const fields = object . getFields ( ) ; Object . keys ( fields ) . forEach ( ( fieldName ) => { const field = fields [ fieldName ] ; if ( 'resolve' in field ) { field . resolve = authenticated ( field . resolve ) ; } } ) ; } }