File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
packages/plugins/other/visitor-plugin-common/src Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphql-codegen/visitor-plugin-common ' : patch
3+ ---
4+
5+ Improve code generation performance by computing ` ClientSideBaseVisitor ` 's ` fragmentsGraph ` once at instantiation time.
Original file line number Diff line number Diff line change @@ -251,7 +251,8 @@ export class ClientSideBaseVisitor<
251251
252252 private _onExecutableDocumentNode ?: Unstable_OnExecutableDocumentNode ;
253253 private _omitDefinitions ?: boolean ;
254- private _fragments : Map < string , LoadedFragment > ;
254+ private readonly _fragments : ReadonlyMap < string , LoadedFragment > ;
255+ private readonly fragmentsGraph : DepGraph < LoadedFragment > ;
255256
256257 constructor (
257258 protected _schema : GraphQLSchema ,
@@ -289,6 +290,7 @@ export class ClientSideBaseVisitor<
289290 this . _onExecutableDocumentNode = ( rawConfig as any ) . unstable_onExecutableDocumentNode ;
290291 this . _omitDefinitions = ( rawConfig as any ) . unstable_omitDefinitions ;
291292 this . _fragments = new Map ( fragments . map ( fragment => [ fragment . name , fragment ] ) ) ;
293+ this . fragmentsGraph = this . _getFragmentsGraph ( ) ;
292294 autoBind ( this ) ;
293295 }
294296
@@ -519,7 +521,7 @@ export class ClientSideBaseVisitor<
519521 ) } ;`;
520522 }
521523
522- private get fragmentsGraph ( ) : DepGraph < LoadedFragment > {
524+ private _getFragmentsGraph ( ) : DepGraph < LoadedFragment > {
523525 const graph = new DepGraph < LoadedFragment > ( { circular : true } ) ;
524526
525527 for ( const fragment of this . _fragments . values ( ) ) {
You can’t perform that action at this time.
0 commit comments