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

fix(metadata): restore original metadata to enable repeated buildSchema executions #1691

Conversation

ghost
Copy link

@ghost ghost commented May 19, 2024

Overview

This PR addresses the issue described in #1321, where the function buildExtendedResolversMetadata alters instance properties, causing multiple calls to buildSchema to exhibit unexpected behavior.

Problem Statement

The primary problem is that buildExtendedResolversMetadata modifies the following instance properties of MetadataStorage:

  • queries
  • mutations
  • subscriptions
  • fieldResolvers

This mutation leads to issues when buildSchema is called multiple times, such as missing arguments in subsequent schema builds, as noted in the original issue.

Solution

The proposed solution in this PR involves preserving the original state of MetadataStorage. On successive calls to buildSchema, the original instance of MetadataStorage is restored, ensuring that repeated schema builds do not encounter the unintended side effects of modified metadata.

Implementation Details

  • Save Original Metadata: Store the initial state of MetadataStorage upon the first invocation of buildSchema.
  • Restore Metadata: Before subsequent calls to buildSchema, restore MetadataStorage to its original state.

@ghost ghost requested a review from MichalLytek as a code owner May 19, 2024 18:46
@MichalLytek MichalLytek assigned ghost May 20, 2024
@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Bugfix 🐛 🔨 PR that fixes a known bug labels May 20, 2024
@ghost ghost marked this pull request as draft May 29, 2024 13:17
@ghost
Copy link
Author

ghost commented May 29, 2024

Further testing showed that this solution has a race condition and does not work for more than two buildSchema runs. I have another solution ready, but I will wait a couple of days to refresh the PR to see if this solution finally works.

@MichalLytek
Copy link
Owner

@syonthomas Actually I've managed to fix this last week in a more reasonable fashion.
Created a PR now, which supersede this PR 🔒

#1698

@MichalLytek MichalLytek added the Wontfix ❌ This will not be worked on label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 🔨 PR that fixes a known bug Community 👨‍👧 Something initiated by a community Wontfix ❌ This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two mounted apollo servers (resolvers with inhertance) – second one lacks ArgsType in query
1 participant