Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const plugin: PluginFunction = (schema: GraphQLSchema, documents: Types.DocumentFile[], config: TypeGraphQLPluginConfig) => {
const visitor = new TypeGraphQLVisitor(schema, config);
const printedSchema = printSchema(schema);
const astNode = parse(printedSchema);
const maybeValue = `export type Maybe = ${visitor.config.maybeValue};`;
const visitorResult = visit(astNode, { leave: visitor });
const introspectionDefinitions = includeIntrospectionDefinitions(schema, documents, config);
const scalars = visitor.scalarsDefinition;
let definitions = visitorResult.definitions;
// Sort output by interfaces first, classes last to prevent TypeScript errors
definitions.sort((definition1, definition2) => (isDefinitionInterface(definition1) ? -1 : 1));
return {
prepend: [...visitor.getEnumsImports(), maybeValue, TYPE_GRAPHQL_IMPORT, DECORATOR_FIX],
content: [scalars, ...definitions, ...introspectionDefinitions].join('\n'),
};
};