@@ -7,6 +7,7 @@ import {DocumentationGenerator} from './docgen/doc'
77import JSDocumentationGenerator from './docgen/jsdoc'
88import NullDocumentationGenerator from './docgen/nulldoc'
99import tsgenFactory from './factory'
10+ import { supportGraphql } from '../util'
1011
1112async function format ( definition : string ) {
1213 const prettierConfig = await prettier . resolveConfig ( process . cwd ( ) )
@@ -26,7 +27,7 @@ function createOutputPath(outputFile: string) {
2627 return outputPath
2728}
2829
29- export default async function tsgenRunner ( outputFile : string , contentTypes : any [ ] , prefix = '' , includeDocumentation = true ) {
30+ export default async function tsgenRunner ( outputFile : string , contentTypes : any [ ] , prefix = '' , includeDocumentation = true , graphql : boolean ) {
3031 const docgen : DocumentationGenerator = includeDocumentation ? new JSDocumentationGenerator ( ) : new NullDocumentationGenerator ( )
3132
3233 const outputPath = createOutputPath ( outputFile )
@@ -40,7 +41,10 @@ export default async function tsgenRunner(outputFile: string, contentTypes: any[
4041 } ,
4142 } )
4243
43- for ( const contentType of contentTypes ) {
44+ for ( let contentType of contentTypes ) {
45+ if ( graphql ) {
46+ contentType = supportGraphql ( contentType )
47+ }
4448 const tsgenResult = tsgen ( contentType )
4549
4650 definitions . push ( tsgenResult . definition )
@@ -52,6 +56,7 @@ export default async function tsgenRunner(outputFile: string, contentTypes: any[
5256
5357 const output = await format (
5458 [
59+
5560 defaultInterfaces ( prefix ) . join ( '\n\n' ) ,
5661 [ ...globalFields ] . join ( '\n\n' ) ,
5762 definitions . join ( '\n\n' ) ,
0 commit comments