outcaste-io / outserv

Blockchain Search with GraphQL APIs
https://manishrjain.com/outserv-graphql-blockchain-search
Other
197 stars 15 forks source link

Figure out type / field renaming #40

Open manishrjain opened 2 years ago

manishrjain commented 2 years ago

We need a solution for renaming a field or a type, without having to rewrite the entire data.

P.S. Have a look at how EdgeDB does this: https://www.edgedb.com/showcase/migrations

benwoodward commented 2 years ago

Fauna have a good tool for this.

https://github.com/fauna-labs/fauna-schema-migrate

Ideally every schema change would be accomplished via a generated migration script that is saved in a commit.

This is how it works in Rails (https://guides.rubyonrails.org/active_record_migrations.html) - you run a CLI command to generate a new migration, it creates a timestamped script, you edit the script and add commands for modifying the schema as well as any logic you might need for manipulating data. Then you run the migrate command and it will sequentially run the migrations up until the latest.

The benefit to this is that team members can easily be on the same schema regardless of what commit they are on.

jdgamble555 commented 2 years ago

I imagine you're going to have a graphql endpoint and an admin endpoint.

Why not just do something like this on the admin endpoint:

mutation {
  renameType('Post', 'Tweet')
}

to rename a Type, and

mutation {
  Post {
    renameField('updated_at', 'updatedAt')
  }
}

to rename a field.

Under the hood it uses the dql mutation

J