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 Flutter App #328

Open
2 of 6 tasks
medz opened this issue Jan 25, 2024 · 62 comments · Fixed by #364 or #377
Open
2 of 6 tasks

Support Flutter App #328

medz opened this issue Jan 25, 2024 · 62 comments · Fixed by #364 or #377

Comments

@medz
Copy link
Owner

medz commented Jan 25, 2024

Prisma Dart Client was originally built for the Dart server-side, and we look forward to introducing it in Flutter.

Progress

@listepo
Copy link

listepo commented Jan 28, 2024

Can not wait:)

@medz
Copy link
Owner Author

medz commented Jan 28, 2024

@listepo
Thank you for looking forward to it, but I don't know how long it will take. Prisma officials have revealed that they are experimenting with the C ABI engine, but have not announced the time or plan.

It is not feasible to implement the C ABI engine as a third party because it has already failed once. After the build is completed, the upstream repo is Prisma's internal engine. They have many destructive commits every day, making it difficult for the downstream to maintain it continuously (especially if it is only me. case)

In order to achieve the unification of Dart Server-side and Flutter, WASM is the best choice. But the real problem is that Dart does not have the ability to load WASM natively. Flutter only experimentally allows Flutter code to be compiled into wasm.

Many helplessness and many problems are like mountains before our eyes, making it difficult to overcome.

@medz medz pinned this issue Jan 28, 2024
@listepo
Copy link

listepo commented Feb 23, 2024

@medz any news?

@medz
Copy link
Owner Author

medz commented Mar 18, 2024

prisma/prisma-engines#4774

The latest news, the C ABI engine of Prisma Engines. Once it is Merge, I will immediately implement the support of Flutter.

@medz medz removed the enhancement label Mar 24, 2024
@medz
Copy link
Owner Author

medz commented Apr 11, 2024

news prisma/prisma-engines#4793

@listepo
Copy link

listepo commented Apr 15, 2024

is there any success?

@medz
Copy link
Owner Author

medz commented Apr 15, 2024

@listepo
image
It has not been merged yet. Once it is merged to produce the C ABI engine, I will follow up immediately.

@medz
Copy link
Owner Author

medz commented Apr 15, 2024

@listepo I noticed that it has been merged, thank you for bringing this matter to my attention again.

I am following up and looking for any information about the C ABI engine and official examples of its use in RN.

At present, it seems to only support SQLite, but it is sufficient, and most Flutter developers do not want to link to remote databases. SQLite+Prisma can help a large number of developers complete local data structure storage and have intuitive CRUD APIs

@listepo
Copy link

listepo commented Apr 15, 2024

@medz I'll be happy to help with testing

@kidusdev
Copy link

Hy @medz i am using prisma-dart for my flutter desktop application. I didn't struggle or have error until now. How can i help?

20240417_104930.jpg

20240417_105050.jpg

All the above data table, numbers and authentication is implemented using prisma-dart.

@medz
Copy link
Owner Author

medz commented Apr 23, 2024

Bad news, I still need to implement a C ABI engine myself. But Prisma has provided a great template

@listepo
Copy link

listepo commented Apr 30, 2024

@medz How is it going? help is needed?

@MulverineX
Copy link
Contributor

MulverineX commented May 11, 2024

still need to implement a C ABI engine myself

why is that? In what way is theirs unsuited for this library? I'm also curious what your timeline is looking like, and am interested in helping, hopefully more than simply testing & working on #281. After getting https://github.com/openwebf/mercury fully working for my usecase, this library is what I'm waiting on to continue with https://github.com/RefractureMedia/refracture-music

edit: just noticed your status, get well soon! I really appreciate all of the work that you've done thusfar on the library! Also, once funds are a little less tight on my end I plan on setting up recurring Sponsorship for your work on this library, I understand that motivation for open source projects can be pretty tough at times.

@MulverineX
Copy link
Contributor

Another potential route this project could take is use of https://github.com/fzyzcjy/flutter_rust_bridge , which appears to be reaching a reliable, efficient, and cross-platform state.

@medz
Copy link
Owner Author

medz commented May 11, 2024

@MulverineX I hope that C Engine can also be applied on the server.

@MulverineX
Copy link
Contributor

MulverineX commented May 11, 2024

What do you mean? flutter_rust_bridge supports server-side Dart applications as well. And as for my other questions?

@medz
Copy link
Owner Author

medz commented May 28, 2024

@MulverineX The desktop architecture is too complex, and each architecture corresponds to an engine. Therefore, during the application startup phase, it is most reasonable to determine whether an engine needs to be downloaded and enter the download waiting page. Otherwise, your desktop app might be very large.

For the mobile side, whether including library files in the app or downloading library files is completed by the developer before building, and the packaging will only include necessary files.

If Prisma provided a dynamic library, this problem would not exist. (But judging from the Prisma roadmap, it is unlikely to be possible for a long time)

@MulverineX
Copy link
Contributor

Flutter requires per arch build regardless, most of the time. What added complexity is there here?

https://github.com/KRTirtho/spotube/releases/tag/v3.6.0

@medz
Copy link
Owner Author

medz commented May 28, 2024

@MulverineX Maybe you're right, it seems complex architecture only happens on Linux. macOS/Windows can include binaries directly. It seems that a special flutter.assets converter needs to be written to solve the schema file problem on Linux. Maybe I’m overcomplicating my thoughts😊

@medz
Copy link
Owner Author

medz commented Jun 2, 2024

image

News: Support flutter Android done.

@medz medz linked a pull request Jun 2, 2024 that will close this issue
@listepo
Copy link

listepo commented Jun 2, 2024

Nice

@listepo
Copy link

listepo commented Jun 2, 2024

@medz maybe it makes sense to rename from orm to prisma_client and orm_flutter to prisma_client_flutter?

@MulverineX
Copy link
Contributor

@listepo I think the goal here is to improve this library to the point where it can be the defacto ORM for Flutter. It wasn't already a taken name, and Prisma is generally the best option out there. Obviously, the engine still needs some query crafting work to improve performance down the road. Still, since Prisma has corporate sponsors/investment I'm confident the team will continue to iterate. Also, since this library directly interacts with the query engine, client isn't exactly appropriate. prisma being in the main description is good enough for searchability.

@medz
Copy link
Owner Author

medz commented Jun 3, 2024

@listepo I originally intended to do this, but the names are all taken (and not actually used). I tried to contact the author and the dart team through the pub.dev guide, but no emails were returned.

@medz
Copy link
Owner Author

medz commented Jun 3, 2024

@listepo Another fact is that the prisma marketing team does not want third-party clients to use short prisma-related names. So you will see that the documentation website of prisma orm for dart was updated to Prisma Client Dart not long ago.

@listepo
Copy link

listepo commented Jun 7, 2024

@medz how to create and use migrations?

@medz
Copy link
Owner Author

medz commented Jun 7, 2024

@listepo Creating migrations is the same as Prisma, using the prisma migrate dev command.

To apply migrations, call the applyMigrations method on the engine

Documentation is here https://prisma.pub/getting-started/flutter.html#migrations

@listepo
Copy link

listepo commented Jun 7, 2024

@medz thanks

@medz medz added the feature label Jun 7, 2024
@MulverineX
Copy link
Contributor

Really looking forward to desktop platforms here, once they're available I can really begin to iterate on my app, as its targeting desktop first.

@listepo
Copy link

listepo commented Jun 21, 2024

internally I'm using Zig. So I may also release a Zig version of Prisma in the future its very intresting

@kidusdev
Copy link

internally I'm using Zig. So I may also release a Zig version of Prisma in the future its very intresting

that would be amazing if Zig took off in the future.

@listepo
Copy link

listepo commented Jul 16, 2024

Any news?

@medz
Copy link
Owner Author

medz commented Jul 16, 2024

Any news?

@listepo Sorry, no new news. Maybe prisma/prisma-engines#4913 is one of the news.

My original plan was to use the binary engine to build macOS/Windows/Linux support (of course, it is not a high priority) but I did not try my best to implement it for the following reasons:

  1. Prisma engine has been working towards the WASM build goal

  2. The binary engine has been phased out since last year (most of the third-party language implementations are still in use)

  3. There is no clear direction for Prisma to move in. I can only work as hard as possible on the engine provided by Prisma, because any implementation of my own can be easily destroyed by the above. (This is not the scope of Prisma's official obligations)

  4. My personal energy is really limited. To put it bluntly, China's current unemployment rate is very high and everyone is working hard to make a living, otherwise they will not be able to eat tomorrow. (I am no exception)

Combining the above, it is difficult for Prisma Dart to make new breakthroughs. Completing similar implementations for most of the Prisma official engine is the best I can do at this point.

@MulverineX
Copy link
Contributor

  1. This could be very powerful, but it does come with a small performance hit
  2. Im not sure what this means, but dont those third party implementations all rely on the binary engine in some way?
  3. Completely understandable, keeping up with constant internal changes would be a massive pain and is infeasible for one person to maintain.
  4. My most sincere condolences, its very difficult to make fulfilling & productive career/hobby choices in such a tight job market. I can sympathize a little, as I've had a tough time finding a software company to take a chance on me. I'm lucky to be living with my parents still though. It seems that most of the world is headed into a recession. I wish I could donate more and/or that some startups would take notice of this project and fund its development 😮‍💨. Good luck out there, hoping that you find some stability and rest soon.

@medz
Copy link
Owner Author

medz commented Jul 16, 2024

@MulverineX

Thank you for your understanding and support.

This could be very powerful, but it does come with a small performance hit

This means that it becomes more difficult to use the Prisma engine in environments that do not support loading WASM natively. Currently, other third-party languages have strong official or community support for loading WASM modules, but Dart does not. The Dart official team is currently committed to using Dart to build WASM modules and has no plans to load WASM modules at the moment.

Im not sure what this means, but dont those third party implementations all rely on the binary engine in some way?

Yes, currently third-party languages are using the Prisma binary engine. But almost all Prisma official clients are no longer used.

As far as I know, the Wasm version of the last Scheme Engine in Prisma's official engine is about to be built. Perhaps after the last remaining binary engine implemented WASM migration, several versions of bug fixes were made. Prisma official will no longer maintain or even completely stop building binary engines (this is just my guess, because continuing to maintain binary engines after all switches to WASM is meaningless for Prisma official and will increase costs)

@MulverineX
Copy link
Contributor

strong official or community support for loading WASM modules, but Dart does not.

luckily this is actually not the case!
https://github.com/juancastillo0/wasm_run

@MulverineX
Copy link
Contributor

MulverineX commented Jul 17, 2024

continuing to maintain binary engines after all switches to WASM is meaningless for Prisma official and will increase costs

not necessarily, Many people will still want to use the system binary engine for better performance.

@listepo
Copy link

listepo commented Jul 17, 2024

yes native code better

@listepo
Copy link

listepo commented Jul 17, 2024

@medz I would like to try to help, could you share the Zig code?

@medz
Copy link
Owner Author

medz commented Jul 17, 2024

@listepo Unfortunately, I deleted it after Prisma released the CABI engine. Because its essence is to use Rust FFI to write C ABI, and then call it from Zig to build a unified engine.

I am sorry that I deleted it after trying this technology (because I gave up the huge upstream dependency work)

Currently, the only thing left of Prisma Dart is the client based on the official Prisma engine.

Again, I am sorry that I no longer have the energy to try new technologies. My current personal plan for Prisma Dart (not disclosed) is as follows:

  1. Stability maintenance (I will fix it once someone submits a bug)

  2. Remove code_buinder from the code base (very low priority, I have always planned to remove code_builder/build_runner/json_serializable, and it took me a long time to successfully remove the build_* ecosystem package)

  3. Migrate fromJson and toJson of // to macros. (Once macros enters the official version of Dart SDK, the experimental flag will not be required)
    
    And my company has already given up using the Zig language. Forgive me for being too busy to do anything else. I can only keep up with the normal bug fixes for the open source project. (Because my company has once again reached the point where I am the only one left, I must find a way to save it and ensure my livelihood)

The reason I tried Zig to write the engine before was that Rust cross-compilation was too complicated, while Zig was much simpler (it can be said that it is very easy to cross-compile)

@medz
Copy link
Owner Author

medz commented Nov 3, 2024

News:

🎉Now @Prisma Dart v5.2.1 is released with @FlutterDev integration v0.4, using a new package architecture:
image

🌲We can easily implement more platform integrations in the future.

https://github.com/medz/prisma-dart/releases/tag/orm-v5.2.1%2Borm_flutter-v0.4.0

@medz
Copy link
Owner Author

medz commented Nov 3, 2024

@kidusdev Hey, the way you integrate Flutter with Prisma in Windows is exactly what I will do next to support macOS, WIndows, and Linux. Interested in contributing it?

There is already a ready-made implementation of the binary engine in the orm package, and the integration of the remaining three platforms is just to make it easier for Flutter Desktop to get the engine (just depend on it)

In the orm_flutter package, it just determines the platform and forwards the engine instance.

This request is because I need to complete more complex web integration, which usually uses WASM and uses lower-level APIs.

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

Successfully merging a pull request may close this issue.

4 participants