import { IGQLCommand } from './types' ; const forEach = ( root , fn ) => { if ( typeof root . commands !== 'object' ) { throw Error ( 'Expected commands object' ) ; } fn ( { command : root , root } ) ; const queue = [ ... Object . values ( root . commands ) ] ; while ( queue . length ) { const command = queue . shift ( ) ; if ( command ) { fn ( { command , root } ) ; if ( command . commands ) { queue . push ( ... Object . values ( command . commands ) ) ; } } } } ; export default forEach ;