mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 21:09:05 +00:00
Update apollo config to fix genSchemaTypes (#1154)
This commit is contained in:
@@ -1,8 +1,38 @@
|
||||
// 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: '../api/graphql/schema.graphql',
|
||||
localSchemaFile: outputPath,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user