mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
Merge pull request #1482 from coralproject/introspection-fix
Introspection fix
This commit is contained in:
@@ -103,16 +103,25 @@ function getIntrospectionQuery(options = {}) {
|
||||
`;
|
||||
}
|
||||
|
||||
const generateIntrospectionResult = (resultLocation, options = {}) =>
|
||||
graphql(schema, getIntrospectionQuery(options)).then(({ data }) => {
|
||||
// Serialize the introspection result as JSON.
|
||||
const introspectionResult = JSON.stringify(data, null, 2);
|
||||
const generateIntrospectionResult = async (resultLocation, options = {}) => {
|
||||
const dir = path.dirname(resultLocation);
|
||||
try {
|
||||
fs.accessSync(dir);
|
||||
} catch (err) {
|
||||
console.log(`Cannot write to ${dir}, not generating introspection.json`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the introspection result to the filesystem.
|
||||
fs.writeFileSync(resultLocation, introspectionResult, 'utf8');
|
||||
const { data } = await graphql(schema, getIntrospectionQuery(options));
|
||||
|
||||
console.log(`Outputted result of introspectionQuery to ${resultLocation}`);
|
||||
});
|
||||
// Serialize the introspection result as JSON.
|
||||
const introspectionResult = JSON.stringify(data, null, 2);
|
||||
|
||||
// Write the introspection result to the filesystem.
|
||||
fs.writeFileSync(resultLocation, introspectionResult, 'utf8');
|
||||
|
||||
console.log(`Outputted result of introspectionQuery to ${resultLocation}`);
|
||||
};
|
||||
|
||||
const graphIntrospectionFilename = path.resolve(
|
||||
__dirname,
|
||||
|
||||
Reference in New Issue
Block a user