@tobiastengler/create-relay-app
Version:
Easy configuration of Relay for existing projects
26 lines (25 loc) • 868 B
JavaScript
import { TaskBase } from "./TaskBase.js";
import { bold } from "../utils/index.js";
const schemaGraphQLContent = `# Replace this with your own GraphQL schema file!
type Query {
field: String
}`;
export class GenerateGraphQlSchemaFileTask extends TaskBase {
constructor(context) {
super();
this.context = context;
this.message = "Generate GraphQL schema file";
}
isEnabled() {
return true;
}
async run() {
this.updateMessage(this.message + " " + bold(this.context.schemaPath.rel));
if (this.context.fs.exists(this.context.schemaPath.abs)) {
this.skip("File exists");
return;
}
await this.context.fs.createDirectory(this.context.schemaPath.parentDirectory);
await this.context.fs.writeToFile(this.context.schemaPath.abs, schemaGraphQLContent);
}
}