Mirror: The small sibling of the graphql package, slimmed down for client-side libraries.
at v16.1.1000 576 B view raw
1import { getLocation } from 'graphql/language/location'; 2 3export function printLocation(location) { 4 return printSourceLocation( 5 location.source, 6 getLocation(location.source, location.start) 7 ); 8} 9 10export function printSourceLocation(source, sourceLocation) { 11 const firstLineColumnOffset = source.locationOffset.column - 1; 12 const lineNum = sourceLocation.line + source.locationOffset.line - 1; 13 const columnNum = 14 sourceLocation.column + sourceLocation.line === 1 15 ? firstLineColumnOffset 16 : 0; 17 return `${source.name}:${lineNum}:${columnNum}`; 18}