[Proposal] Surgical updates on schema file #2136
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
When a user runs
pull, we overwrite their schema file with ours. This can end up removing important parts of their code:. For example:Attempted solutions
We have an
--experimental-type-preservationoption, which (a) parses current schema file, and (b) the new schema file. We then update (b) the new schema file with type hints from (a).The problem with this approach, is that it can be (1) error prone: we'll have to selectively "move over" all the locally defined stuff to the new file, and (2) it still loses information: comments, order etc.
New Idea
In this PR, we go for a different idea:
updateSchemaFile.Given (a) the local file (b) the local InstantSchemaDef, and (c) the Server InstantSchemaDef:
diffSchemasThis way we only update what we need to update.
Drawbacks
This is reasonably complicated. We may still have trouble updating things, if the original schema file gets more complicated.
But it should get us to a much more robust state.
@dwwoelfel @nezaj @drew-harris