How to use the graphql-language-service-utils.getASTNodeAtPosition 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 / GraphQLLanguageService.js View on Github external
position: Position,
    filePath: Uri,
  ): Promise {
    const graphQLConfig = this._graphQLRC.getConfigByFilePath(filePath);
    if (!graphQLConfig) {
      return null;
    }

    let ast;
    try {
      ast = parse(query);
    } catch (error) {
      return null;
    }

    const node = getASTNodeAtPosition(query, ast, position);
    switch (node ? node.kind : null) {
      case FRAGMENT_SPREAD:
        return this._getDefinitionForFragmentSpread(
          query,
          ast,
          node,
          filePath,
          graphQLConfig,
        );
      case FRAGMENT_DEFINITION:
      case OPERATION_DEFINITION:
        return getDefinitionQueryResultForDefinitionNode(
          filePath,
          query,
          node,
        );
github graphql / graphiql / packages / graphql-language-service-interface / src / GraphQLLanguageService.ts View on Github external
async getDefinition(
    query: string,
    position: Position,
    filePath: Uri,
  ): Promise {
    const projectConfig = this.getConfigForURI(filePath);

    let ast;
    try {
      ast = parse(query);
    } catch (error) {
      return null;
    }

    const node = getASTNodeAtPosition(query, ast, position);
    if (node) {
      switch (node.kind) {
        case FRAGMENT_SPREAD:
          return this._getDefinitionForFragmentSpread(
            query,
            ast,
            node,
            filePath,
            projectConfig,
          );

        case FRAGMENT_DEFINITION:
        case OPERATION_DEFINITION:
          return getDefinitionQueryResultForDefinitionNode(
            filePath,
            query,