Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const plugin: PluginFunction = async (schema: GraphQLSchema, documents: Types.DocumentFile[], config: JavaResolversPluginRawConfig, { outputFile }): Promise => {
const relevantPath = dirname(normalize(outputFile));
const defaultPackageName = buildPackageNameFromPath(relevantPath);
const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
const printedSchema = printSchema(schema);
const astNode = parse(printedSchema);
const visitorResult = visit(astNode, { leave: visitor as any });
const mappersImports = visitor.getImports();
const packageName = visitor.getPackageName();
const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
const wrappedContent = visitor.wrapWithClass(blockContent);
return [packageName, mappersImports, wrappedContent].join('\n');
};
constructor(_schema: GraphQLSchema, rawConfig: JavaApolloAndroidPluginConfig, private _availableFragments: LoadedFragment[]) {
super(_schema, rawConfig, {
package: rawConfig.package || buildPackageNameFromPath(process.cwd()),
fragmentPackage: rawConfig.fragmentPackage || 'fragment',
typePackage: rawConfig.typePackage || 'type',
});
}