Skip to content

Commit

Permalink
Pass along the schema derived data computed during SchemaManager cons…
Browse files Browse the repository at this point in the history
…truction to start()
  • Loading branch information
sachindshinde committed Sep 27, 2021
1 parent 09953f9 commit 06344fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/apollo-server-core/src/utils/schemaManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class SchemaManager {
| {
readonly mode: 'schema';
readonly apiSchema: GraphQLSchema;
readonly schemaDerivedData: SchemaDerivedData;
};

constructor(
Expand All @@ -69,10 +70,11 @@ export class SchemaManager {
this.modeSpecificState = {
mode: 'schema',
apiSchema: options.apiSchema,
// The caller of the constructor expects us to fail early if the schema
// given is invalid/has errors, so we call the provider here. We also
// pass the result to start(), as the provider can be expensive to call.
schemaDerivedData: options.schemaDerivedDataProvider(options.apiSchema),
};
// The caller of the constructor expects us to fail early if the schema
// given is invalid/has errors, so we call the provider here.
options.schemaDerivedDataProvider(options.apiSchema);
}
}

Expand Down Expand Up @@ -121,7 +123,7 @@ export class SchemaManager {
} else {
this.processSchemaLoadOrUpdateEvent({
apiSchema: this.modeSpecificState.apiSchema,
});
}, this.modeSpecificState.schemaDerivedData);
return null;
}
}
Expand Down Expand Up @@ -209,11 +211,11 @@ export class SchemaManager {

private processSchemaLoadOrUpdateEvent(
schemaContext: GraphQLSchemaContext,
schemaDerivedData?: SchemaDerivedData,
): void {
if (!this.isStopped) {
this.schemaDerivedData = this.schemaDerivedDataProvider(
schemaContext.apiSchema,
);
this.schemaDerivedData = schemaDerivedData
?? this.schemaDerivedDataProvider(schemaContext.apiSchema);
this.schemaContext = schemaContext;
this.onSchemaLoadOrUpdateListeners.forEach((listener) => {
try {
Expand Down

0 comments on commit 06344fe

Please sign in to comment.