How to use the graphql-language-service-utils.offsetToPosition function in graphql-language-service-utils

To help you get started, we’ve selected a few graphql-language-service-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql / graphiql / src / interfaces / getDefinition.js View on Github external
function getDefinitionForFragmentDefinition(
  path: Uri,
  text: string,
  definition: FragmentDefinitionNode,
): Definition {
  return {
    path,
    position: offsetToPosition(text, definition.name.loc.start),
    range: locToRange(text, definition.loc),
    name: definition.name.value,
    language: LANGUAGE,
    // This is a file inside the project root, good enough for now
    projectRoot: path,
  };
}
github graphql / graphiql / src / interfaces / getOutline.js View on Github external
const meta = node => ({
    representativeName: node.name,
    startPosition: offsetToPosition(docText, node.loc.start),
    endPosition: offsetToPosition(docText, node.loc.end),
    children: node.selectionSet || [],
  });
  return {
github graphql / graphiql / packages / graphql-language-service-interface / src / getDefinition.ts View on Github external
function getPosition(text: string, node: ASTNode): Position {
  const location = node.loc as Location;
  invariant(location, 'Expected ASTNode to have a location.');
  return offsetToPosition(text, location.start);
}
github graphql / graphiql / packages / graphql-language-service-interface / src / getOutline.ts View on Github external
const meta = (node: any) => ({
    representativeName: node.name,
    startPosition: offsetToPosition(docText, node.loc.start),
    endPosition: offsetToPosition(docText, node.loc.end),
    children: node.selectionSet || [],
  });
github graphql / graphiql / src / interfaces / getOutline.js View on Github external
const meta = node => ({
    representativeName: node.name,
    startPosition: offsetToPosition(docText, node.loc.start),
    endPosition: offsetToPosition(docText, node.loc.end),
    children: node.selectionSet || [],
  });
  return {