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, rawDocuments: Types.DocumentFile[], config: FlowDocumentsPluginConfig) => {
const documents = config.flattenGeneratedTypes ? optimizeOperations(schema, rawDocuments) : rawDocuments;
let prefix = `type $Pick = $ObjMapi(k: Key) => $ElementType>;\n`;
const allAst = concatAST(
documents.reduce((prev, v) => {
return [...prev, v.content];
}, [])
);
const allFragments: LoadedFragment[] = [
...(allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION) as FragmentDefinitionNode[]).map(fragmentDef => ({ node: fragmentDef, name: fragmentDef.name.value, onType: fragmentDef.typeCondition.name.value, isExternal: false })),
...(config.externalFragments || []),
];
const visitorResult = visit(allAst, {
leave: new FlowDocumentsVisitor(schema, config, allFragments),
});
export const plugin: PluginFunction = (schema: GraphQLSchema, rawDocuments: Types.DocumentFile[], config: TypeScriptDocumentsPluginConfig) => {
const documents = config.flattenGeneratedTypes ? optimizeOperations(schema, rawDocuments) : rawDocuments;
const allAst = concatAST(
documents.reduce((prev, v) => {
return [...prev, v.content];
}, [])
);
const allFragments: LoadedFragment[] = [
...(allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION) as FragmentDefinitionNode[]).map(fragmentDef => ({ node: fragmentDef, name: fragmentDef.name.value, onType: fragmentDef.typeCondition.name.value, isExternal: false })),
...(config.externalFragments || []),
];
const visitorResult = visit(allAst, {
leave: new TypeScriptDocumentsVisitor(schema, config, allFragments),
});
const result = visitorResult.definitions.join('\n');