p2panda / fishy

Create, manage and deploy p2panda schemas
GNU Affero General Public License v3.0
9 stars 1 forks source link

Use fishy as a crate to read `schema.lock` and deploy / migrate it automatically #3

Open Corban-Dallas opened 1 year ago

Corban-Dallas commented 1 year ago

Hello!

I am trying to write a decentralized book library app to get familiar with p2panda. Thanks for this great protocol, I think you do amazing job.

It would be nice to have something like fishy as a create to be able to read schemas from lock file and to deploy them to node by GraphQL client or just endpoint.

For example, it would be convenient to provide predefined schema.lock within application bundle, to initialize local offline app's node with these schemas.

Something like:

use fishy;

fn initializeApplicationNode {
    // create and start node...
    // prepare GraphQL client if needed...

    // Create LockFile
    // from path
    let path = Path::from("schema.lock");
    let lock_file = LockFile::from(path).unwrap();
    // from String
    let file_content = String::from("...readed content...");
    let lock_file = LockFile::from(file_content).unwrap();

    // import schema
    let schema: Vec<Schema> = lock_file.to_schema().ok();

    // Deploy
    fishy::deploy_lock_file(lock_file, client).ok();
    fishy::deploy_schema(schema, client).ok();
}

or may be something different but doing same job.

adzialocha commented 1 year ago

Hi @Corban-Dallas! Wow, the book library app sounds cool. You can also reach out on our chat https://wald.liebechaos.org if you need some help or have any questions.

It would be nice to have something like fishy as a create to be able to read schemas from lock file and to deploy them to node by GraphQL client or just endpoint.

That's a great idea! We've been thinking about something similar but didn't realize that fishy would be a good place for it.

In the Meli Android app we're currently building we've implemented a similar flow. Whenever the app starts it automatically migrates to the latest version of the schemas based on the schema.lock file: https://github.com/p2panda/meli/blob/main/packages/app/lib/io/p2panda/schemas.dart#L31 - parts of this code are very much inspired by the fishy deploy logic.

Do you want to prepare a PR for this?

Corban-Dallas commented 1 year ago

You can also reach out on our chat https://wald.liebechaos.org/ if you need some help or have any questions.

Was trying to, but during registration nothing happens when I press "Join your team". May be some problem from my side, I'm using Firefox.

In the Meli Android app we're currently building we've implemented a similar flow. Whenever the app starts it automatically migrates to the latest version of the schemas based on the schema.lock file: https://github.com/p2panda/meli/blob/main/packages/app/lib/io/p2panda/schemas.dart#L31 - parts of this code are very much inspired by the fishy deploy logic.

Thanks, I will take a look. My original idea was to hide QraphQL client from Dart-side and provide convenient interface of rust-library where all fetching with predefined queries would be happening, so this library can be easily used anywhere, for example in ios-swift app as well.

Do you want to prepare a PR for this?

I am not good enough for this for now =) I am Swift developer, only familiarize myself with Rust and Dart. For now It is just a training project on the stack, nothing serious.

adzialocha commented 1 year ago

Was trying to, but during registration nothing happens when I press "Join your team". May be some problem from my side, I'm using Firefox.

That's probably related to a weird issue with RocketChat where passwords not following the password policy get rejected but without notification in the UI .. (in the console one can observe the error message). I don't know how to fix this issue in RocketChat, but I just turned off the strict password policy. Let me know if it works again!

Thanks, I will take a look. My original idea was to hide QraphQL client from Dart-side and provide convenient interface of rust-library where all fetching with predefined queries would be happening, so this library can be easily used anywhere, for example in ios-swift app as well.

Great!

I am not good enough for this for now =) I am Swift developer, only familiarize myself with Rust and Dart. For now It is just a training project on the stack, nothing serious.

Ah cool, then we'll tackle this in the future. Might get back for some input.

sandreae commented 1 year ago

Started exploring ideas here: https://github.com/p2panda/fishy/pull/11

Happy for any feeback @adzialocha & @Corban-Dallas