graphdoc icon indicating copy to clipboard operation
graphdoc copied to clipboard

how to generate doc from a folder

Open candysmurf opened this issue 7 years ago • 1 comments

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.

candysmurf avatar Sep 28 '18 12:09 candysmurf

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
});

chrisae avatar Nov 05 '19 20:11 chrisae