Files
photoview/ui/apollo.config.js
2025-01-09 19:51:39 +01:00

39 lines
984 B
JavaScript

// apollo.config.js
const { readdirSync, readFileSync, writeFileSync, mkdirSync } = require('node:fs');
const path = require('node:path');
const schemasFolder = path.join(__dirname, '..', 'api', 'graphql', 'resolvers');
let completeSchema;
try {
completeSchema = readdirSync(schemasFolder)
.filter(x => x.endsWith('.graphql'))
.map(x => {
const filePath = path.join(schemasFolder, x);
return readFileSync(filePath, 'utf-8');
})
.join('\n\n');
} catch (error) {
console.error('Failed to generate schema:', error);
process.exit(1);
}
const outputPath = path.join(__dirname, '.cache', 'schema.graphql');
try {
mkdirSync(path.dirname(outputPath), { recursive: true });
writeFileSync(outputPath, completeSchema, { mode: 0o644 });
} catch (error) {
console.error('Failed to write schema file:', error);
process.exit(1);
}
module.exports = {
client: {
service: {
name: 'photoview',
localSchemaFile: outputPath,
},
},
}