Files
photoview/ui/apollo.config.js
Kostiantyn a8edb30ae4 Refactor Docker build workflows (#1221)
* Initial implementation

* Multiple fixes and improvemens

* Better `curl` retries timing

* Remove unused `TARGETOS` and `TARGETVARIANT` vars; add the version fetch fallback code to the build scripts

* Move the fallback code before the var usage

* Use double braces to make the code compatible with the `set -u`

---------

Co-authored-by: Konstantin Koval
2025-06-26 11:58:50 +03:00

39 lines
983 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,
},
},
}