Skip to content

Conversation

@stopachka
Copy link
Contributor

@stopachka stopachka commented Dec 20, 2025

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:

  1. Special imports
  2. Type overrides
  3. Special order they had
  4. Other code inside the file

Attempted solutions

We have an --experimental-type-preservation option, 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:

  1. We run diffSchemas
  2. We find the exact i.schema call in the AST
  3. We then take diffs and 'apply' them on the local file

This 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

@github-actions
Copy link
Contributor

View Vercel preview at instant-www-js-surgical-jsv.vercel.app.

@stopachka stopachka changed the title [in-progress] Surgical updates on schema file [Proposal] Surgical updates on schema file Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants