How to use the relay-compiler.Runner function in relay-compiler

To help you get started, weโ€™ve selected a few relay-compiler 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 kiwicom / mobile / app / relay / scripts / RelayCompiler.js View on Github external
getFileFilter: RelayJSModuleParser.getFileFilter,
      getParser: RelayJSModuleParser.getParser,
      getSchema: () => getSchema(schemaPath),
      watchmanExpression: useWatchman ? buildWatchExpression(options) : null,
      filepaths: useWatchman ? null : getFilepathsFromGlob(srcDir, options),
    },
  };
  const writerConfigs = {
    default: {
      getWriter: getRelayFileWriter(srcDir),
      isGeneratedFile: (filePath: string) =>
        filePath.endsWith('.js') && filePath.includes('__generated__'),
      parser: 'default',
    },
  };
  const codegenRunner = new CodegenRunner({
    reporter,
    parserConfigs,
    writerConfigs,
    onlyValidate: options.validate,
  });
  if (!options.validate && !options.watch) {
    // eslint-disable-next-line no-console
    console.log('HINT: pass --watch to keep watching for changes.');
  }
  const result = options.watch
    ? await codegenRunner.watchAll()
    : await codegenRunner.compileAll();

  if (result === 'ERROR') {
    process.exit(100);
  }
github yusinto / relay-compiler-plus / src / compiler / main.js View on Github external
extensions: ['graphql'],
        include: ['**'],
        exclude: excludeGraphql,
      }),
    },
  };
  const writerConfigs = {
    js: {
      getWriter: getRelayFileWriter(srcDir, persistQuery),
      isGeneratedFile: (filePath: string) =>
        filePath.endsWith('.js') && filePath.includes('__generated__'),
      parser: 'js',
      baseParsers: ['graphql'],
    },
  };
  const codegenRunner = new CodegenRunner({
    reporter,
    parserConfigs,
    writerConfigs,
    onlyValidate: false,
    sourceControl: null,
  });

  let result = '';
  try {
    // the real work is done here
    result = await codegenRunner.compileAll();
  } catch (err) {
    console.log(`Error codegenRunner.compileAll(): ${err}`);
    throw err;
  }
github yusinto / relay-compiler-plus / src / compiler / main.js View on Github external
extensions: ['graphql'],
        include: options.include,
        exclude: options.exclude,
      }),
    },
  };
  const writerConfigs = {
    js: {
      getWriter: getRelayFileWriter(srcDir, persistQuery),
      isGeneratedFile: (filePath: string) =>
        filePath.endsWith('.js') && filePath.includes('__generated__'),
      parser: 'js',
      baseParsers: ['graphql'],
    },
  };
  const codegenRunner = new CodegenRunner({
    reporter,
    parserConfigs,
    writerConfigs,
    onlyValidate: false,
    sourceControl: null,
  });

  let result = '';
  try {
    // the real work is done here
    result = await codegenRunner.compileAll();
  } catch (err) {
    console.log(`Error codegenRunner.compileAll(): ${err}`);
    throw err;
  }
github relay-tools / relay-compiler-webpack-plugin / src / index.js View on Github external
compilation: Compilation,
    hooks: PluginHooks,
  ): Promise {
    let logger;

    // webpack 4.38+
    if (compilation.getLogger) {
      logger = compilation.getLogger('RelayCompilerPlugin');
    }

    const reporter = this.options.getReporter
      ? this.options.getReporter(logger)
      : createRaiseErrorsReporter(logger);

    // Can this be set up in constructor and use same instance every time?
    const runner = new Runner({
      parserConfigs: this.parserConfigs,
      writerConfigs: this.writerConfigs,
      reporter,
      onlyValidate: false,
      skipPersist: true,
    });

    return hooks.beforeWrite.promise()
      .then(() => runner.compile(this.languagePlugin.outputExtension))
      .then((compileResult) => hooks.afterWrite.promise(compileResult));
  }
github relay-tools / relay-compiler-webpack-plugin / dist / index.js View on Github external
async compile(issuer, request, compilation, hooks) {
    let logger; // webpack 4.38+

    if (compilation.getLogger) {
      logger = compilation.getLogger('RelayCompilerPlugin');
    }

    const reporter = this.options.getReporter ? this.options.getReporter(logger) : (0, _createRaiseErrorsReporter.default)(logger); // Can this be set up in constructor and use same instance every time?

    const runner = new _relayCompiler.Runner({
      parserConfigs: this.parserConfigs,
      writerConfigs: this.writerConfigs,
      reporter,
      onlyValidate: false,
      skipPersist: true
    });
    return hooks.beforeWrite.promise().then(() => runner.compile(this.languagePlugin.outputExtension)).then(compileResult => hooks.afterWrite.promise(compileResult));
  }