Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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;
}
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;
}
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));
}
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));
}