How to use the graphql-language-service-utils.resolveFile 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 / packages / graphql-language-service-interface / src / GraphQLLanguageService.ts View on Github external
try {
      validationAst = parse(source);
    } catch (error) {
      // the query string is already checked to be parsed properly - errors
      // from this parse must be from corrupted fragment dependencies.
      // For IDEs we don't care for errors outside of the currently edited
      // query, so we return an empty array here.
      return [];
    }

    // Check if there are custom validation rules to be used
    let customRules;
    const customRulesModulePath = extensions.customValidationRules;
    if (customRulesModulePath) {
      /* eslint-disable no-implicit-coercion */
      const rulesPath = resolveFile(customRulesModulePath);
      if (rulesPath) {
        const customValidationRules = await requireFile(rulesPath);
        if (customValidationRules) {
          customRules = customValidationRules(this._graphQLConfig);
        }
      }
      /* eslint-enable no-implicit-coercion */
    }
    const schema = await this._graphQLCache
      .getSchema(projectName, queryHasExtensions)
      .catch(() => null);

    if (!schema) {
      return [];
    }