Programmatic usage:
// from forked repo:
const typesGenerate = require('./sources/main');
// or
const typesGenerate = require('graphql-types-generator');
async function main() {
await typesGenerate({
filename: './examples/mutations.js',
// ...other options
});
}
main();
filename: string - path to js file with graphql queries wrapped to tagged template gql (possible to use glob pattern) (required)files?: string[] - as alternative filename option allowing multiple source files passing at same timedeclarateSource?: Array<string> - list of files for generating declaration (*.d.ts) files (may match with files option. useful for covering query argument types).declTemplate?: string - file name of template using for *.d.ts files generation (look up examples directory)target?: string - target file nameattachTypeName?: boolean - attach __typename field for each query typematchTypeNames?: boolean - attach 'QueryTypes' typeuseServerTypes?: boolean - using server types for generationscreentypes?: boolean - set human understandable type names for specific graphql types (JSONstring, Base64String and DateString by default)rules?: object - naming rules to generate types like {number: ['count', 'amount']} (applies if the server type is not found or disabled)overRules?: object - rules over server types (override server types!). For example: {cursor: 'Base64String'}separateFileForArgumentsTypes?: boolean - separate argument types and queries result typesverbose?: boolean - includes additional logs output to the consolewatch?: boolean | number - watch mode (number by default is the delay between flogging the file (by default is 250 ms))