How to use the apollo-codegen-core/lib/loading.loadQueryDocuments function in apollo-codegen-core

To help you get started, we’ve selected a few apollo-codegen-core 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 apollographql / apollo-tooling / packages / apollo / src / helpers / commands / queries / commonTasks.ts View on Github external
task: (ctx, task) => {
    // Make sure the expectations of our context are correct.
    assert.strictEqual(typeof ctx.queryDocuments, "undefined");

    ctx.queryDocuments = loadQueryDocuments(
      ctx.documentSets[0].documentPaths,
      flags.tagName
    );
    task.title = `Scanning for GraphQL queries (${
      ctx.queryDocuments.length
    } found)`;
  }
});
github apollographql / apollo-tooling / packages / apollo / src / config.ts View on Github external
const loadAsAST = () => {
    const ast = loadQueryDocuments([referredSchema.schema!])[0];
    if (referredSchema.clientSide) {
      visit(ast, {
        enter(node) {
          if (node.kind == "FieldDefinition") {
            (node as any).__client = true;
          }
        }
      });
    }

    return ast;
  };
github apollographql / apollo-tooling / packages / apollo-cli / src / commands / schema / checkQueries.ts View on Github external
task: async (ctx, task) => {
          const docs = loadQueryDocuments(ctx.queryPaths, flags.tagName);

          const errors: GraphQLError[] = [];
          const warnings: GraphQLError[] = []

          docs.forEach((doc, i) => {
            const validateResult = validate(ctx.schema, doc);
            const deprecationResult = findDeprecatedUsages(ctx.schema, doc);

            errors.push(...validateResult);
            warnings.push(...deprecationResult);

            task.title = `Checking query compatibility with schema (${i + 1}/${docs.length}, ${errors.length} errors, ${warnings.length} warnings)`;
            return validateResult.concat(deprecationResult);
          });

          if (errors.length > 0 || warnings.length > 0) {