Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apollo-server-core: Stop computing schema-derived data twice for non-gateway modes of operation #5757

Conversation

sachindshinde
Copy link
Contributor

Running the schema-derived data provider in SchemaManager.ts can be expensive. Currently, SchemaManager computes this twice for non-gateway modes of operation:

  1. Once during SchemaManager construction (as the caller expects errors to be caught early here).
  2. Once during SchemaManager.start() (as we naively call it within SchemaManager.processSchemaLoadOrUpdateEvent()).

This PR:

  • Changes SchemaManager.processSchemaLoadOrUpdateEvent() to accept an optional schemaDerivedData argument, which (if provided) causes it to store that and skip calling the schema-derived data provider.
  • Changes the constructor to store the results of calling the schema-derived-data provider in mode-specific state, so that it may be passed to start().

Fixes #5729 .

@sachindshinde sachindshinde force-pushed the sachin/stop-computing-schema-derived-data-twice branch from 06344fe to 8850ed7 Compare September 27, 2021 23:36
@glasser glasser self-assigned this Sep 28, 2021
@glasser
Copy link
Member

glasser commented Sep 29, 2021

Looks great! I'll add a CHANGELOG entry.

@glasser glasser enabled auto-merge (squash) September 29, 2021 00:14
@glasser glasser force-pushed the sachin/stop-computing-schema-derived-data-twice branch from bb42a3c to 4c9750b Compare September 29, 2021 00:20
@glasser glasser force-pushed the sachin/stop-computing-schema-derived-data-twice branch from 4c9750b to 91c9df8 Compare September 29, 2021 00:24
@glasser glasser enabled auto-merge (squash) September 29, 2021 00:24
@glasser glasser merged commit 5f8e586 into apollographql:main Sep 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema derived data is computed twice
2 participants