graphdoc
graphdoc copied to clipboard
how to generate doc from a folder
I would like to generate graphQL docs from a source folder which has multiple sub-folders where files with .graphqls suffix. Is there a way to do it? thanks.
Not directly related to graphdoc. You can either traverse the folders and read all graphqls files or you can use shelljs to find all files and concat them:
const shell = require('shelljs');
const gqlFiles = shell.find('./schemas-folder/').filter(function(file) { return file.match(/\.graphqls$/); });
let distSchemaString = '';
gqlFiles.forEach(file => {
distSchemaString += shell.cat(file).toString();
distSchemaString += '\n'; // linebreak between files
});