import { DocumentNode , TypeDefinitionNode } from 'graphql' ; export default function getQueryName ( query ) { if ( query . definitions . length > 0 ) { const def = query . definitions [ 0 ] as TypeDefinitionNode ; return def ?. name ?. value || 'query' ; } return query ?. loc ?. source ?. name || 'query' ; }