Mirror: The small sibling of the graphql package, slimmed down for client-side libraries.
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 = sourceLocation.column + sourceLocation.line === 1 ? firstLineColumnOffset : 0; 14 return `${source.name}:${lineNum}:${columnNum}`; 15}