import { FieldNode , GraphQLResolveInfo , SelectionSetNode } from "graphql" ; /**
* Get field name from node
*/ export const getFieldName = ( node ) => { return node . alias ? node . alias . value : node . name . value ; } ; param info param selectionSet param { } fields param { { } } relations export const visitNodes = ( info , selectionSet , fields , relations ) => { for ( const selection of selectionSet . selections ) { if ( selection . kind === 'Field' ) { const responseName = this . getFieldName ( selection ) ; if ( selection . selectionSet ) { relations [ responseName ] = [ ] ; this . visitNodes ( info , selection . selectionSet , relations [ responseName ] , relations ) ; } else { fields . push ( responseName ) ; } } else if ( selection . kind === 'InlineFragment' ) { this . visitNodes ( info , selection . selectionSet , fields , relations ) ; } else if ( selection . kind === 'FragmentSpread' ) { const fragment = info . fragments [ selection . name . value ] ; this . visitNodes ( info , fragment . selectionSet , fields , relations ) ; } } } ;