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

Support renaming one schema field into multiple new schema fields #810

Open
obi1kenobi opened this issue Apr 29, 2020 · 1 comment
Open

Comments

@obi1kenobi
Copy link
Contributor

The current code assumes that we always want to perform a 1-1 renaming of schema fields: rename a given existing field into a new field. However, this presents a catch-22 migration problem. Imagine you have a query that uses the field being renamed — you can't rename the field without breaking the query, and you can't modify the query to use the new name because the new name isn't present in the schema yet.

One way to avoid this issue is to change the type signature of the renamings argument, making it Dict[str, List[str]] mapping existing schema field names into a list of renamed field names, each of which represents the same underlying schema field. It also presents a unique opportunity to streamline our interfaces: mapping a field to the empty list can represent suppressing the field entirely. Field names X that exist in the schema but are not in the renamings mapping are defined to be equivalent to being mapped to [X], the identity mapping.

This approach resolves the catch-22 migration problem: we are able to update the schema to contain both the original and the desired new field name, then update the query to use the new name, then update the schema again to remove the original field name, completing the migration.

@LWprogramming
Copy link
Collaborator

LWprogramming commented Jul 20, 2020

List of the remaining tasks, for reference:

  • Error checking improvements (various: e.g. every renaming in renamings must be used, error on 1:1 renaming something to itself, raise all errors at once instead of one per invalid GraphQL name, etc)

  • Suppress fields

  • Suppress enums & interfaces (edge case with suppressing implementation but not the original interface)

  • Code cleanup (i.e. if we can get away with not storing O(schema size) data in reverse_name_map and not needing query_type as a parameter anymore)

  • 1-1 and 1-many renaming for enum values as well as fields (whether belonging to object or interface). Requires modifying rename_query as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants