import fs from 'fs'; import path from 'path'; function delay(ms: number) { return new Promise((resolve) => { setTimeout(resolve, ms); }); } async function readSchema(root: string, count = 0): Promise { if (count > 5) { throw new Error('Cannot read schema'); } await delay(2000); try { const key = path.resolve(root, '../graphql/root.graphql'); return fs.readFileSync(key).toString(); } catch (error) { return readSchema(root, count + 1); } } export async function getRootSchema() { const root = process.cwd(); const schema = await readSchema(root); const rootSchemaPath = path.resolve(root, 'src/expo-schema/types/root.graphql'); fs.writeFileSync(rootSchemaPath, schema); }